UnixOperatingSystem.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Oct 2004 21:50:42 +0200
changeset 8618 b78c623be1f7
parent 8601 bf2b973a9a0e
child 8672 f93733514fec
permissions -rw-r--r--
disabled clock_gettime for now - temporary !
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
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    13
"{ Package: 'stx:libbasic' }"
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    14
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
AbstractOperatingSystem subclass:#UnixOperatingSystem
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    16
	instanceVariableNames:''
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
    17
	classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
    18
		LastTimeInfo LastTimeInfoSeconds LastTimeInfoMilliseconds
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
    19
		LastTimeInfoIsLocal CachedMountPoints CacheMountPointsTimeStamp'
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    20
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    21
	category:'OS-Unix'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    22
!
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    23
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    24
Object subclass:#FileDescriptorHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    25
	instanceVariableNames:'fd'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    26
	classVariableNames:'OpenFiles'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    27
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    28
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    29
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    30
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    31
OSFileHandle subclass:#FilePointerHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    32
	instanceVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    33
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    34
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    35
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    36
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    37
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    38
Object subclass:#FileStatusInfo
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    39
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    40
		numLinks'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    41
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    42
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    43
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    46
Object subclass:#MountInfo
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    47
	instanceVariableNames:'mountPointPath deviceOrRemotePath fsType attributeString'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    48
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    49
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    50
	privateIn:UnixOperatingSystem
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    51
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    52
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    53
Object subclass:#OSProcessStatus
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    54
	instanceVariableNames:'pid status code core'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    55
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    56
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    57
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    60
UnixOperatingSystem::FileDescriptorHandle subclass:#SocketHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    61
	instanceVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    62
	classVariableNames:'ProtocolCache'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    63
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    64
	privateIn:UnixOperatingSystem
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    65
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    66
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!UnixOperatingSystem primitiveDefinitions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
#if defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
# ifndef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
#  define WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
#ifdef LINUX
8618
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    79
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    80
/*
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    81
 * please think of a solution to this -
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    82
 * can it be solved without dynamic linking of librt.so ?
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    83
 */ 
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    84
# define NO_CLOCK_GETTIME
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    85
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    86
# define __xxUSE_GNU      /* new */
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    87
# undef HAS_UTS_DOMAINNAME
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
    88
# define NET_IF_SUPPORT
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    89
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    90
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    91
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    92
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    93
# endif
3956
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    94
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    95
# ifndef _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    96
#  include <sys/types.h>
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    97
#  define _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    98
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
  /* use inline string macros */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
# define __STRINGDEFS__
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
   101
# include "linuxIntern.h"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
# define WANT_SHM
3544
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
   107
# define HAS_SETENV
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
   108
# define HAS_UNSETENV
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
   109
# include <time.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
#ifdef ultrix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
#ifdef hpux
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
#ifdef solaris
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
#if defined(SYSV4) && defined(i386) /* e.g. unixware */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
 * notice: although many systems' include files
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
 * already block against multiple inclusion, some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
 * do not. Therefore, this is done here again.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
 * (it does not hurt)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   137
 */
3496
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
#ifdef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
# ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
#  include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
#  define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
# endif
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
# include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
# define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
# include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
# define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
#endif /* WANT_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
extern int shmctl(), shmget(), shmdt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
extern char * shmat();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
# include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
# define _SYS_TYPES_H_INCLUDED_
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
# include <sys/ipc.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
# define _SYS_IPC_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
# include <sys/shm.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
# define _SYS_SHM_H_INCLUDED_
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
#endif /* WANT_SHM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
# include <sys/syssgi.h>
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
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
#ifdef transputer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
#else /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
# ifdef SYSV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
#  ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
#   include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
#   define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
#  ifndef _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
#   ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
#    include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
#    define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
#  ifndef _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
#   include <sys/times.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
#   define _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
#  ifndef _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
#   include <sys/file.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
#   define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
#  if ! defined(sco3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
#   ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
#    include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
#    define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
#  if defined(isc3_2) || defined(sco3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
#   ifndef _SYS_TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
#    include <sys/time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
#    define _SYS_TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
#  if !defined(isc3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
#   if defined(PCS) && defined(mips)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
#    include "/usr/include/bsd/sys/time.h"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
#    include "/usr/include/sys/time.h"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
#    ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
#     include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
#     define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
#    endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
#  if defined(isc3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
#   include <sys/bsdtypes.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
# else /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   241
#  ifndef _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   242
#   include <sys/time.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   243
#   define _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   244
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   245
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   246
#  ifndef _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   247
#   include <sys/types.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   248
#   define _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   249
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   250
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
# endif /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
# ifdef aix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
#  ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
#   include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
#   define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
#  ifndef _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
#   include <sys/select.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
#   define _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
# endif /* aix */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   267
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   268
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   269
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   270
# endif
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   271
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   272
# ifndef _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   273
#  include <pwd.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   274
#  define _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   275
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   276
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   277
# ifndef NO_GRP_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   278
#  ifndef _GRP_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   279
#   include <grp.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   280
#   define _GRP_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
#  endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   282
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   283
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
# ifndef _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
#  include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
#  define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
# ifndef _SYS_FILE_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   291
#  include <sys/file.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
#  define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
# ifndef _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
#  include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
#  define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
# ifndef _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
#  include <fcntl.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
#  define _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   305
# ifndef _SYS_IOCTL_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   306
#  include <sys/ioctl.h>
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   307
#  define _SYS_IOCTL_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
# if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
#  define HAS_LOCALECONV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
# if defined (HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
#  ifndef _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
#   include <locale.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
#   define _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
#  endif
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
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   321
# if defined (HAS_FTIME)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   322
#  include <sys/timeb.h>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   323
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   324
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   325
/*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   326
 * posix systems should define these ...
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
 * but on some (older) systems, they are not.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
#  ifdef S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
#   define S_IXUSR S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
#   define S_IXGRP (S_IEXEC>>3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
#   define S_IXOTH (S_IEXEC>>6)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
#  define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
#  define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
#  define S_IXOTH 0001
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
# ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
#  define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
#  define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
#  define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
# ifndef S_IWUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
#  define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
#  define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
#  define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
# ifndef MAXPATHLEN
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   356
#  ifndef NO_SYS_PARAM_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   357
#   include <sys/param.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
#  ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
#   ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
#    define MAXPATHLEN FILENAME_MAX
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
#    ifdef MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
#     define MAXPATHLEN MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
#    else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
#     define MAXPATHLEN 1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
#    endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
# if defined(HAS_UNAME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
#  include <sys/utsname.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
# if defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
#  include <stropts.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
4285
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   380
# ifndef aix
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   381
#  include <sys/termios.h>
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   382
# endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   383
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
 * NeXT has no pid_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
 * and no sigemptyset
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
# ifdef NEXT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
   typedef int pid_t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
#  define sigemptyset(set)      ((*(set) = 0L), 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
#  define HAS_GETDOMAINNAME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
#  define NO_WAITPID
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
# ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
#  undef NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
#  undef HAS_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
#  define HAS_WAIT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
#  define HAS_SIGACTION
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
 * some (BSD ?) have no timezone global,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
 * but provide the info in struct timezone.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
# if defined(ultrix) || defined(sunos) || defined(NEXT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
#  define HAS_NO_TIMEZONE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
 * 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
   412
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
# ifndef SA_RESTART
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
#  define SA_RESTART    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
# ifndef SA_SIGINFO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
#  define SA_SIGINFO    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
# if defined(HAS_SYSINFO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
#  include <sys/systeminfo.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   428
# ifdef LINUX
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   429
#  include <linux/kernel.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   430
#  include <linux/sys.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   431
# endif
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   432
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   433
# if defined(HAS_GETSYSINFO)
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   434
#  include <sys/sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   435
#  include <machine/hal_sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   436
#  include <machine/hal/cpuconf.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   437
# endif
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   438
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   439
# if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   440
#  ifndef _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   441
#   include <unistd.h>
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   442
#   define _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   443
#  endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   444
# endif
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   445
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
#endif /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
7709
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   448
#ifndef NO_SOCKET
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   449
# include <netdb.h>
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   450
#endif
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   451
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
 * 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
   454
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
#ifndef errno
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
 extern errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
 * some (old ?) systems do not define this ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
#if !defined(R_OK) && !defined(_AIX)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   463
# 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
   464
# define W_OK    2       /* Test for Write permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
# define X_OK    1       /* Test for eXecute permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
# 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
   467
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   469
#define SIGHANDLER_ARG
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
#ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
#ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
 * not all systems have time_t and off_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
 * explicit add of those we know to have ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
#ifdef __osf__
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
# define TIME_T time_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
# define OFF_T  off_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
#ifndef TIME_T
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
# define TIME_T long
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
#ifndef OFF_T
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
# define OFF_T  long
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
 * where is the timezone info ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
 */
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   497
#ifdef HAS_TM_GMTOFF
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   498
# define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   499
#else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   500
# if defined(HAS_NO_TIMEZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   501
#  if defined(HAS_NO_TM_GMTOFF)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   502
#   define TIMEZONE(tmPtr)       0
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   503
#  else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   504
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   505
#  endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
# else
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   507
#  if defined(HAS_ALTZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   508
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : altzone)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   509
#  else  /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   510
#   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
   511
#  endif /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   512
# endif
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   513
#endif
3595
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   514
#ifndef CONST
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   515
# ifdef __GNUC__
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   516
#  define CONST const
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   517
# else
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   518
#  define CONST /* nothing */
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   519
# endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   520
#endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   521
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   522
#ifndef        FORK
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   523
# if defined(HAS_VFORK)
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   524
#  define     FORK            vfork
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   525
# else
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   526
#  define     FORK            fork
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   527
# endif
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   528
#endif
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   529
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   530
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   531
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   532
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   533
 * Socket defines
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   534
 */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
   535
#include "stxOSDefs.h"
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
   536
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   537
#ifdef NET_IF_SUPPORT  /* for mac address of interfaces */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   538
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   539
# ifndef _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   540
#  include <net/if.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   541
#  define _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   542
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   543
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   544
# ifndef _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   545
#  include <sys/ioctl.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   546
#  define _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   547
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   548
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   549
#endif /* NET_IF_SUPPORT */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   550
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   551
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   552
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   553
#if defined(TRY_AGAIN) || defined(HOST_NOT_FOUND)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   554
# define USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   555
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   556
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   557
#ifdef USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   558
# ifndef h_errno
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   559
 extern h_errno;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   560
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   561
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   562
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
%}
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
!UnixOperatingSystem primitiveFunctions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
/*
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   570
 * 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
   571
 * 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
   572
 * (LINUX is one of them)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
 * 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
   574
 * UnixOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
 * 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
   576
 *
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
 * 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
   578
 * 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
   579
 * (i.e. it is RT safe)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
#if defined(WANT_SYSTEM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
/* # define DPRINTF(x)     printf x */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
# define DPRINTF(x)     /* nothing */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
# ifndef _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
#  include <stddef.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
#  define _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
# ifndef _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
#  include <stdlib.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
#  define _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
# ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
#  include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
#  define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
# ifndef _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
#  define _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
# endif
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
# ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
#  include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
#  define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
# 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
   618
#  define       __environ       environ
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   619
#  if 1 /* !defined(LINUX) */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
#   define      __sigemptyset   sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
#   define      __sigaction     sigaction
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
#   define      __sigaddset     sigaddset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
#   define      __sigprocmask   sigprocmask
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
#   define      __execve        execve
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
#   define      __wait          wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
#   define      __waitpid       waitpid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
#  endif /* ! LINUX */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
   extern char **environ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   631
# define      __sigprocmask   sigprocmask
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   632
# define      __execve        execve
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   633
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
# 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
   635
# define        SHELL_NAME      "sh"            /* Name to give it.  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
static int
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
mySystem(line)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
    register CONST char *line;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
    int status, save;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    pid_t pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
    struct sigaction sa, intr, quit;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
    sigset_t block, omask;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    if (line == NULL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   648
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
    sa.sa_handler = SIG_IGN;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
    sa.sa_flags = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
    __sigemptyset (&sa.sa_mask);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   655
	DPRINTF(("1: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   656
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   659
	save = errno;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   660
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   661
	errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   662
	DPRINTF(("2: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   663
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
    __sigemptyset (&block);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
    __sigaddset (&block, SIGCHLD);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   670
	if (errno == ENOSYS)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   671
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   672
	else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   673
	    save = errno;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   674
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   675
	    (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   676
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   677
	    DPRINTF(("3: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   678
	    return -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   679
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
    pid = FORK ();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
    if (pid == (pid_t) 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   684
	/* Child side.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   685
	CONST char *new_argv[4];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   686
	new_argv[0] = SHELL_NAME;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   687
	new_argv[1] = "-c";
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   688
	new_argv[2] = line;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   689
	new_argv[3] = NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   690
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   691
	/* Restore the signals.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   692
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   693
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   694
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   695
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   696
	/* Exec the shell.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   697
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   698
	_exit (127);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   700
	if (pid < (pid_t) 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   701
	    /* The fork failed.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   702
	    DPRINTF(("4: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   703
	    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   704
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   705
	    /* Parent side.  */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
#ifdef  NO_WAITPID
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   707
	    pid_t child;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   708
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   709
	    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   710
		__BEGIN_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   711
		child = __wait (&status);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   712
		__END_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   713
		if (child < 0 && errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   714
		    DPRINTF(("5: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   715
		    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   716
		    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   717
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   718
	    } while (child != pid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
#else
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   720
	    pid_t child;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   721
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   722
	    /* claus: the original did not care for EINTR here ... */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   723
	    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   724
		__BEGIN_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   725
		child = __waitpid (pid, &status, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   726
		__END_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   727
	    } while ((child != pid) && (errno == EINTR));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   728
	    if (child != pid) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   729
		DPRINTF(("6: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   730
		status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   731
	    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
#endif /* NO_WAITPID */
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   733
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   736
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   739
	if (errno == ENOSYS) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   740
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   741
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   742
	    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   743
	    DPRINTF(("7: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   744
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
    return status;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
# define __wait wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
#endif /* WANT_SYSTEM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
 * some systems do not have realpath();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
 * the alternative of reading from a 'pwp'-pipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
 * 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
   758
 * 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
   759
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
#if defined(HAS_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
#if defined(WANT_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
# ifndef NULL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
#  define NULL (char *)0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
# define MAX_READLINKS 32
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
# ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
#  define MAXPATHLEN     1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
static
6357
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   781
char *
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   782
realpath(path, resolved_path)
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   783
    char *path;
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   784
    char resolved_path [];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
{
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   786
	char copy_path[MAXPATHLEN];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   787
	char link_path[MAXPATHLEN];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   788
	char *new_path = resolved_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   789
	char *max_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   790
	int readlinks = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   791
	int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   792
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   793
	/* 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
   794
	strcpy(copy_path, path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   795
	path = copy_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   796
	max_path = copy_path + MAXPATHLEN - 2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   797
	/* 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
   798
	if (*path != '/') {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
#ifdef HAS_GETCWD
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   800
		new_path = getcwd(new_path, MAXPATHLEN - 1);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
#else
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   802
		new_path = getwd(new_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   803
#endif
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   804
		if (new_path == NULL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   805
		    return(NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   806
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   807
		new_path += strlen(new_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   808
		if (new_path[-1] != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   809
			*new_path++ = '/';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   810
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   811
	else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   812
		*new_path++ = '/';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   813
		path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   814
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   815
	/* Expand each slash-separated pathname component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   816
	while (*path != '\0') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   817
		/* Ignore stray "/". */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   818
		if (*path == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   819
			path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   820
			continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   821
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   822
		if (*path == '.') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   823
			/* Ignore ".". */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   824
			if (path[1] == '\0' || path[1] == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   825
				path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   826
				continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   827
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   828
			if (path[1] == '.') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   829
				if (path[2] == '\0' || path[2] == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   830
					path += 2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   831
					/* Ignore ".." at root. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   832
					if (new_path == resolved_path + 1)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   833
						continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   834
					/* Handle ".." by backing up. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   835
					while ((--new_path)[-1] != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   836
						;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   837
					continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   838
				}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   839
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   840
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   841
		/* Safely copy the next pathname component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   842
		while (*path != '\0' && *path != '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   843
			if (path > max_path) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   844
				errno = ENAMETOOLONG;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   845
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   846
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   847
			*new_path++ = *path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   848
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
#ifdef S_IFLNK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   850
		/* Protect against infinite loops. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   851
		if (readlinks++ > MAX_READLINKS) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   852
			errno = ELOOP;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   853
			return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   854
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   855
		/* See if latest pathname component is a symlink. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   856
		*new_path = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   857
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   858
		if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   859
			/* 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
   860
			if (errno != EINVAL)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   861
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   862
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   863
		else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   864
			/* Note: readlink doesn't add the null byte. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   865
			link_path[n] = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   866
			if (*link_path == '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   867
				/* Start over for an absolute symlink. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   868
				new_path = resolved_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   869
			else
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   870
				/* Otherwise back up over this component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   871
				while (*(--new_path) != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   872
					;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   873
			/* Safe sex check. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   874
			if (strlen(path) + n >= MAXPATHLEN) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   875
				errno = ENAMETOOLONG;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   876
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   877
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   878
			/* Insert symlink contents into path. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   879
			strcat(link_path, path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   880
			strcpy(copy_path, link_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   881
			path = copy_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   882
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
#endif /* S_IFLNK */
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   884
		*new_path++ = '/';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   885
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   886
	/* 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
   887
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   888
		new_path--;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   889
	/* Make sure it's null terminated. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   890
	*new_path = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   891
	return resolved_path;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
# define HAS_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
#endif /* WANT_REALPATH && not HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
copyright
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
 COPYRIGHT (c) 1988 by Claus Gittinger
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   904
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
 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
   907
 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
   908
 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
   909
 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
   910
 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
   911
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   912
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   915
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
    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
   918
    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
   919
    things available here in your applications
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
    - 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
   921
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
    (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
   923
     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
   924
     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
   925
     You decide - portability vs. functionality)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
    [Class variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   929
	HostName        <String>        remembered hostname
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   930
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   931
	DomainName      <String>        remembered domainname
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   932
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   933
	SlowFork        <Boolean>       if set, fork and popen are avoided;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   934
					(more or less obsolete now)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   935
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   936
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   937
	CurrentDirectory <String>       remembered currentDirectories path
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
    [author:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   940
	Claus Gittinger
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   941
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
    [see also:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   943
	OSProcessStatus
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   944
	Filename Date Time
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   945
	ExternalStream FileStream PipeStream Socket
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   947
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   948
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
examples
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
  various queries
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   952
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   953
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   954
	showCR:'hello ' , (OperatingSystem getLoginName)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   955
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   956
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   957
								[exBegin]
3793
aff27e755ffd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   958
    OperatingSystem isUNIXlike ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   959
	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
   960
    ] ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   961
	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
   962
    ]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   963
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   964
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   965
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   966
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   967
	showCR:'this machine is called ' , OperatingSystem getHostName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   968
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   969
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   970
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   971
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   972
	showCR:('this machine is in the '
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   973
	       , OperatingSystem getDomainName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   974
	       , ' domain')
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   975
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   976
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   977
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   978
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   979
	showCR:('this machine''s CPU is a '
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   980
	       , OperatingSystem getCPUType
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   981
	       )
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   982
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   983
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   984
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
    Transcript showCR:'executing ls command ...'.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
   986
    OperatingSystem executeCommand:'ls'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
    Transcript showCR:'... done.'.
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   988
								[exEnd]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   990
  locking a file
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
  (should be executed on two running smalltalks - not in two threads):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   992
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
    |f|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
    f := 'testFile' asFilename readWriteStream.
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
    10 timesRepeat:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   998
	'about to lock ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   999
	[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1000
	  OperatingSystem
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1001
	    lockFD:(f fileDescriptor)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1002
	    shared:false
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1003
	    blocking:false
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1004
	] whileFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1005
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1006
	    Delay waitForSeconds:1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1007
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1008
	'LOCKED ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1009
	Delay waitForSeconds:10.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1010
	'unlock ...' printCR.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1011
	(OperatingSystem
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1012
	    unlockFD:(f fileDescriptor)) printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1013
	Delay waitForSeconds:3.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
    ]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1015
								[exBegin]
3496
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
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
!UnixOperatingSystem class methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
initialize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
    "initialize the class"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
    ObjectMemory addDependent:self.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
    HostName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
    DomainName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    LastErrorNumber := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
    PipeFailed := false.
4395
53122eb3ce70 clear ForkFailed flag; made it a classVar
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1029
    ForkFailed := false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
    SlowFork := false.
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1031
    CurrentDirectory := nil.
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1032
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1033
    "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
  1034
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
update:something with:aParameter from:changedObject
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
    "catch image restart and flush some cached data"
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
    something == #earlyRestart ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1040
	"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1041
	 flush cached data/info
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1042
	"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1043
	HostName := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1044
	DomainName := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1045
	LastErrorNumber := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1046
	PipeFailed := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1047
	SlowFork := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1048
	ForkFailed := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1049
	CurrentDirectory := nil.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1052
    "Created: / 15.6.1996 / 15:22:37 / cg"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1053
    "Modified: / 7.1.1997 / 19:36:11 / stefan"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1054
    "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
  1055
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
!UnixOperatingSystem class methodsFor:'OS signal constants'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
sigABRT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
    "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
  1061
     (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
  1062
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1063
    ^ self signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1064
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1065
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1066
     OperatingSystem sigABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1067
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
sigALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
    "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
  1072
     (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
  1073
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1074
    ^ self signalNamed:#SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1075
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1076
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1077
     OperatingSystem sigALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1078
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
sigBREAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
    "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
  1083
     This is an MSDOS specific signal"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1085
    ^ self signalNamed:#SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1086
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1087
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1088
     OperatingSystem sigBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1089
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
sigBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
    "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
  1094
     (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
  1095
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1096
    ^ self signalNamed:#SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1097
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1098
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1099
     OperatingSystem sigBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1100
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
sigCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
    "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
  1105
     (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
  1106
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1107
    ^ self signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1108
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1109
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1110
     OperatingSystem sigCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1111
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
sigCONT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
    "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
  1116
     (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
  1117
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1118
    ^ self signalNamed:#SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1119
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1120
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1121
     OperatingSystem sigCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1122
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
sigDANGER
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
    "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
  1127
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1129
    ^ self signalNamed:#SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1130
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1131
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1132
     OperatingSystem sigDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1133
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
sigEMT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
    "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
  1138
     (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
  1139
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1140
    ^ self signalNamed:#SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1141
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1142
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1143
     OperatingSystem sigEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1144
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
sigFP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
    "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
  1149
     (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
  1150
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1151
    ^ self signalNamed:#SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1152
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1153
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1154
     OperatingSystem sigFP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1155
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
sigGRANT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
    "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
  1160
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1162
    ^ self signalNamed:#SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1163
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1164
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1165
     OperatingSystem sigGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1166
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1167
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1168
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
sigHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
    "return the signal number for SIGHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
     (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
  1172
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1173
    ^ self signalNamed:#SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1174
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1175
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1176
     OperatingSystem sigHUP
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
sigILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
    "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
  1183
     (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
  1184
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1185
    ^ self signalNamed:#SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1186
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1187
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1188
     OperatingSystem sigILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1189
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
sigINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
    "return the signal number for SIGINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
     (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
  1195
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1196
    ^ self signalNamed:#SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1197
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1198
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1199
     OperatingSystem sigINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1200
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1203
sigIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
    "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
  1205
     (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
  1206
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1207
    ^ self signalNamed:#SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1208
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1209
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1210
     OperatingSystem sigIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1211
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
sigIOT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
    "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
  1216
     (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
  1217
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1218
    ^ self signalNamed:#SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1219
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1220
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1221
     OperatingSystem sigIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1222
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1223
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
sigKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
    "return the signal number for SIGKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
     (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
  1228
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1229
    ^ self signalNamed:#SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1230
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1231
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1232
     OperatingSystem sigKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1233
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1234
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1236
sigLOST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
    "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
  1238
     (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
  1239
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1240
    ^ self signalNamed:#SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1241
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1242
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1243
     OperatingSystem sigLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1244
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1246
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1247
sigMIGRATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
    "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
  1249
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1251
    ^ self signalNamed:#SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1252
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1253
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1254
     OperatingSystem sigMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1255
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1256
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1257
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
sigMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
    "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
  1260
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1262
    ^ self signalNamed:#SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1263
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1264
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1265
     OperatingSystem sigMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1266
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1267
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1268
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
sigPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
    "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
  1271
     (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
  1272
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1273
    ^ self signalNamed:#SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1274
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1275
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1276
     OperatingSystem sigPIPE
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1279
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1280
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1281
sigPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
    "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
  1283
     (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
  1284
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1285
    ^ self signalNamed:#SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1286
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1287
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1288
     OperatingSystem sigPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1289
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1290
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1292
sigPRE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
    "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
  1294
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1295
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1296
    ^ self signalNamed:#SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1297
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1298
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1299
     OperatingSystem sigPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1300
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1301
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1302
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1303
sigPROF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
    "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
  1305
     (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
  1306
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1307
    ^ self signalNamed:#SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1308
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1309
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1310
     OperatingSystem sigPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1311
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
sigPWR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
    "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
  1316
     (not available on all systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1318
    ^ self signalNamed:#SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1319
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1320
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1321
     OperatingSystem sigPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1322
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1324
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1325
sigQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
    "return the signal number for SIGQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1327
     (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
  1328
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1329
    ^ self signalNamed:#SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1330
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1331
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1332
     OperatingSystem sigQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1333
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1334
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1335
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1336
sigRETRACT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1337
    "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
  1338
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1340
    ^ self signalNamed:#SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1341
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1342
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1343
     OperatingSystem sigRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1344
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1345
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
sigSAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
    "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
  1350
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1352
    ^ self signalNamed:#SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1353
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1354
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1355
     OperatingSystem sigSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1356
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1357
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1359
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
sigSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
    "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
  1362
     (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
  1363
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1364
    ^ self signalNamed:#SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1365
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1366
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1367
     OperatingSystem sigSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1368
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1369
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1370
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
sigSOUND
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
    "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
  1374
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1376
    ^ self signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1377
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1378
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1379
     OperatingSystem sigSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1380
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1381
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
sigSTOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
    "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
  1386
     (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
  1387
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1388
    ^ self signalNamed:#SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1389
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1390
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1391
     OperatingSystem sigSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1392
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1393
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
sigSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
    "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
  1397
     (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
  1398
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1399
    ^ self signalNamed:#SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1400
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1401
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1402
     OperatingSystem sigSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1403
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1404
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1405
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
sigTERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
    "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
  1408
     (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
  1409
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1410
    ^ self signalNamed:#SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1411
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1412
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1413
     OperatingSystem sigTERM
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1416
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1417
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
sigTRAP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
    "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
  1420
     (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
  1421
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1422
    ^ self signalNamed:#SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1423
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1424
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1425
     OperatingSystem sigTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1426
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1427
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
sigTSTP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
    "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
  1431
     (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
  1432
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1433
    ^ self signalNamed:#SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1434
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1435
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1436
     OperatingSystem sigTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1437
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
sigTTIN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
    "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
  1442
     (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
  1443
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1444
    ^ self signalNamed:#SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1445
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1446
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1447
     OperatingSystem sigTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1448
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
sigTTOU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
    "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
  1453
     (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
  1454
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1455
    ^ self signalNamed:#SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1456
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1457
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1458
     OperatingSystem sigTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1459
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
sigURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
    "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
  1464
     (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
  1465
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1466
    ^ self signalNamed:#SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1467
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1468
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1469
     OperatingSystem sigURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1470
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1471
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1473
sigUSR1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1474
    "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
  1475
     (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
  1476
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1477
    ^ self signalNamed:#SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1478
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1479
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1480
     OperatingSystem sigUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1481
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
sigUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
    "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
  1486
     (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
  1487
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1488
    ^ self signalNamed:#SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1489
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1490
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1491
     OperatingSystem sigUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1492
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
sigVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
    "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
  1497
     (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
  1498
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1499
    ^ self signalNamed:#SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1500
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1501
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1502
     OperatingSystem sigVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1503
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
sigWINCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
    "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
  1508
     (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
  1509
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1510
    ^ self signalNamed:#SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1511
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1512
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1513
     OperatingSystem sigWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1514
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1515
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1516
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1517
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1518
sigXCPU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1519
    "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
  1520
     (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
  1521
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1522
    ^ self signalNamed:#SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1523
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1524
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1525
     OperatingSystem sigXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1526
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1527
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1528
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1529
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1530
sigXFSZ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1531
    "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
  1532
     (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
  1533
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1534
    ^ self signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1535
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1536
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1537
     OperatingSystem sigXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1538
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1539
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1540
!
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1541
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1542
signalNamed:signalName
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1543
    "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
  1544
     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
  1545
     (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
  1546
      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
  1547
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
%{  /* NOCONTEXT */
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1549
#ifdef SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1550
    if (signalName == @symbol(SIGABRT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1551
	RETURN ( __MKSMALLINT(SIGABRT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1552
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1553
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1554
#ifdef SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1555
    if (signalName == @symbol(SIGALRM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1556
	RETURN ( __MKSMALLINT(SIGALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1557
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1558
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1559
#ifdef SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1560
    if (signalName == @symbol(SIGBREAK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1561
	RETURN ( __MKSMALLINT(SIGBREAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1562
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1563
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1564
#ifdef SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1565
    if (signalName == @symbol(SIGBUS)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1566
	RETURN ( __MKSMALLINT(SIGBUS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1567
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1568
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1569
#ifdef SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1570
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1571
     || (signalName == @symbol(SIGCLD)) ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1572
	RETURN ( __MKSMALLINT(SIGCHLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1573
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
#else
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1575
# if defined(SIGCLD)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1576
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1577
     || (signalName == @symbol(SIGCLD)) ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1578
	RETURN ( __MKSMALLINT(SIGCLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1579
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1580
# endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1581
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1582
#ifdef SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1583
    if (signalName == @symbol(SIGCONT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1584
	RETURN ( __MKSMALLINT(SIGCONT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1585
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1586
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1587
#ifdef SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1588
    if (signalName == @symbol(SIGDANGER)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1589
	RETURN ( __MKSMALLINT(SIGDANGER) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1590
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1591
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1592
#ifdef SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1593
    if (signalName == @symbol(SIGEMT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1594
	RETURN ( __MKSMALLINT(SIGEMT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1595
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1596
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1597
#ifdef SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1598
    if (signalName == @symbol(SIGFPE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1599
	RETURN ( __MKSMALLINT(SIGFPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1600
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1601
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1602
#ifdef SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1603
    if (signalName == @symbol(SIGGRANT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1604
	RETURN ( __MKSMALLINT(SIGGRANT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1605
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1606
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1607
#ifdef SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1608
    if (signalName == @symbol(SIGHUP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1609
	RETURN ( __MKSMALLINT(SIGHUP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1610
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1611
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1612
#ifdef SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1613
    if (signalName == @symbol(SIGILL)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1614
	RETURN ( __MKSMALLINT(SIGILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1615
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1616
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1617
#ifdef SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1618
    if (signalName == @symbol(SIGINT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1619
	RETURN ( __MKSMALLINT(SIGINT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1620
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1621
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1622
#ifdef SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1623
    if (signalName == @symbol(SIGIO)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1624
	RETURN ( __MKSMALLINT(SIGIO) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1625
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1626
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1627
#ifdef SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1628
    if (signalName == @symbol(SIGIOT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1629
	RETURN ( __MKSMALLINT(SIGIOT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1630
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1631
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1632
#ifdef SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1633
    if (signalName == @symbol(SIGKILL)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1634
	RETURN ( __MKSMALLINT(SIGKILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1635
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1636
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1637
#ifdef SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1638
    if (signalName == @symbol(SIGLOST)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1639
	RETURN ( __MKSMALLINT(SIGLOST) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1640
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1641
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1642
#ifdef SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1643
    if (signalName == @symbol(SIGMIGRATE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1644
	RETURN ( __MKSMALLINT(SIGMIGRATE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1645
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1646
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1647
#ifdef SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1648
    if (signalName == @symbol(SIGMSG)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1649
	RETURN ( __MKSMALLINT(SIGMSG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1650
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1651
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1652
#ifdef SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1653
    if (signalName == @symbol(SIGPIPE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1654
	RETURN ( __MKSMALLINT(SIGPIPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1655
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1656
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1657
#ifdef SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1658
    if (signalName == @symbol(SIGPOLL)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1659
	RETURN ( __MKSMALLINT(SIGPOLL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1660
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1661
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1662
#ifdef SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1663
    if (signalName == @symbol(SIGPRE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1664
	RETURN ( __MKSMALLINT(SIGPRE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1665
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1666
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1667
#ifdef SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1668
    if (signalName == @symbol(SIGPROF)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1669
	RETURN ( __MKSMALLINT(SIGPROF) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1670
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1671
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1672
#ifdef SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1673
    if (signalName == @symbol(SIGPWR)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1674
	RETURN ( __MKSMALLINT(SIGPWR) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1675
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1676
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1677
#ifdef SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1678
    if (signalName == @symbol(SIGQUIT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1679
	RETURN ( __MKSMALLINT(SIGQUIT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1680
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1681
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1682
#ifdef SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1683
    if (signalName == @symbol(SIGRETRACT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1684
	RETURN ( __MKSMALLINT(SIGRETRACT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1685
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1686
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1687
#ifdef SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1688
    if (signalName == @symbol(SIGSAK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1689
	RETURN ( __MKSMALLINT(SIGSAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1690
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1691
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1692
#ifdef SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1693
    if (signalName == @symbol(SIGSEGV)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1694
	RETURN ( __MKSMALLINT(SIGSEGV) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1695
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1696
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1697
#ifdef SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1698
    if (signalName == @symbol(SIGSOUND)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1699
	RETURN ( __MKSMALLINT(SIGSOUND) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1700
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1701
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1702
#ifdef SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1703
    if (signalName == @symbol(SIGSTOP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1704
	RETURN ( __MKSMALLINT(SIGSTOP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1705
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1706
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1707
#ifdef SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1708
    if (signalName == @symbol(SIGSYS)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1709
	RETURN ( __MKSMALLINT(SIGSYS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1710
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1711
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1712
#ifdef SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1713
    if (signalName == @symbol(SIGTERM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1714
	RETURN ( __MKSMALLINT(SIGTERM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1715
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1716
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1717
#ifdef SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1718
    if (signalName == @symbol(SIGTRAP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1719
	RETURN ( __MKSMALLINT(SIGTRAP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1720
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1721
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1722
#ifdef SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1723
    if (signalName == @symbol(SIGTSTP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1724
	RETURN ( __MKSMALLINT(SIGTSTP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1725
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1726
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1727
#ifdef SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1728
    if (signalName == @symbol(SIGTTIN)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1729
	RETURN ( __MKSMALLINT(SIGTTIN) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1730
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1731
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1732
#ifdef SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1733
    if (signalName == @symbol(SIGTTOU)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1734
	RETURN ( __MKSMALLINT(SIGTTOU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1735
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1736
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1737
#ifdef SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1738
    if (signalName == @symbol(SIGURG)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1739
	RETURN ( __MKSMALLINT(SIGURG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1740
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1741
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1742
#ifdef SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1743
    if (signalName == @symbol(SIGUSR1)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1744
	RETURN ( __MKSMALLINT(SIGUSR1) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1745
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1746
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1747
#ifdef SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1748
    if (signalName == @symbol(SIGUSR2)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1749
	RETURN ( __MKSMALLINT(SIGUSR2) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1750
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1751
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1752
#ifdef SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1753
    if (signalName == @symbol(SIGVTALRM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1754
	RETURN ( __MKSMALLINT(SIGVTALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1755
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1756
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1757
#ifdef SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1758
    if (signalName == @symbol(SIGWINCH)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1759
	RETURN ( __MKSMALLINT(SIGWINCH) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1760
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1761
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1762
#ifdef SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1763
    if (signalName == @symbol(SIGXCPU)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1764
	RETURN ( __MKSMALLINT(SIGXCPU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1765
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1766
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1767
#ifdef SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1768
    if (signalName == @symbol(SIGXFSZ)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1769
	RETURN ( __MKSMALLINT(SIGXFSZ) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1770
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1771
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1772
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
    RETURN ( __MKSMALLINT(0) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1774
%}
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1775
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1776
     OperatingSystem signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1777
     OperatingSystem signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1778
     OperatingSystem signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1779
     OperatingSystem signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1780
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1781
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1782
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1783
!UnixOperatingSystem class methodsFor:'error messages'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1784
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1785
currentErrorNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1786
    "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
  1787
     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
  1788
     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
  1789
     request to the OS.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1790
     Use lastErrorNumber - currentErrorNumber is invalidated by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
     many, many internal calls."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1794
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1795
     RETURN ( __MKSMALLINT(errno) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1797
     "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  1798
      OperatingSystem currentErrorNumber
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1799
     "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1800
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1802
errorHolderForNumber:errNr
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1803
    "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
  1804
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1805
    |sym typ holder|
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1806
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1807
%{
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1808
    /* claus:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1809
     * I made this primitive code, since errnos are not
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1810
     * standard across unixes
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1811
     */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1812
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1813
    typ = @symbol(defaultOsErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1814
    sym = @symbol(ERROR_OTHER);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1815
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1816
    if (__isSmallInteger(errNr)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1817
	switch ( __intVal(errNr)) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1818
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1819
	     * POSIX errnos - these should be defined
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1820
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1821
#ifdef EPERM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1822
	    case EPERM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1823
		sym = @symbol(EPERM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1824
		typ = @symbol(noPermissionsSignal);
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 ENOENT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1828
	    case ENOENT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1829
		sym = @symbol(ENOENT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1830
		typ = @symbol(nonexistentSignal);
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 ESRCH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1834
	    case ESRCH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1835
		sym = @symbol(ESRCH);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1836
		typ = @symbol(unavailableReferentSignal);
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
#ifdef EINTR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1840
	    case EINTR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1841
		sym = @symbol(EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1842
		typ = @symbol(transientErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1843
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1844
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1845
#ifdef EIO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1846
	    case EIO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1847
		sym = @symbol(EIO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1848
		typ = @symbol(transferFaultSignal);
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 ENXIO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1852
	    case ENXIO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1853
		sym = @symbol(ENXIO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1854
		typ = @symbol(unavailableReferentSignal);
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 E2BIG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1858
	    case E2BIG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1859
		sym = @symbol(E2BIG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1860
		typ = @symbol(invalidArgumentsSignal);
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 ENOEXEC
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1864
	    case ENOEXEC:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1865
		sym = @symbol(ENOEXEC);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1866
		typ = @symbol(inappropriateOperationSignal);
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 EBADF
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1870
	    case EBADF:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1871
		sym = @symbol(EBADF);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1872
		typ = @symbol(badAccessorSignal);
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 ECHILD
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1876
	    case ECHILD:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1877
		sym = @symbol(ECHILD);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1878
		typ = @symbol(informationSignal);
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
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1882
	    case EAGAIN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1883
		sym = @symbol(EAGAIN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1884
		typ = @symbol(notReadySignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1885
		break;
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  1886
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  1887
#ifdef EOVERFLOW
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1888
	    case EOVERFLOW:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1889
		sym = @symbol(EOVERFLOW);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1890
		typ = @symbol(rangeErrorSignal);
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 ENOMEM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1894
	    case ENOMEM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1895
		sym = @symbol(ENOMEM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1896
		typ = @symbol(noMemorySignal);
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 EACCES
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1900
	    case EACCES:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1901
		sym = @symbol(EACCES);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1902
		typ = @symbol(noPermissionsSignal);
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 EFAULT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1906
	    case EFAULT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1907
		sym = @symbol(EFAULT);
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 EBUSY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1912
	    case EBUSY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1913
		sym = @symbol(EBUSY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1914
		typ = @symbol(unavailableReferentSignal);
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 EEXIST
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1918
	    case EEXIST:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1919
		sym = @symbol(EEXIST);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1920
		typ = @symbol(existingReferentSignal);
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 EXDEV
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1924
	    case EXDEV:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1925
		sym = @symbol(EXDEV);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1926
		typ = @symbol(inappropriateReferentSignal);
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 ENODEV
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1930
	    case ENODEV:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1931
		sym = @symbol(ENODEV);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1932
		typ = @symbol(inaccessibleSignal);
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 ENOTDIR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1936
	    case ENOTDIR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1937
		sym = @symbol(ENOTDIR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1938
		typ = @symbol(inappropriateOperationSignal);
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 EISDIR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1942
	    case EISDIR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1943
		sym = @symbol(EISDIR);
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 EINVAL
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1948
	    case EINVAL:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1949
		sym = @symbol(EINVAL);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1950
		typ = @symbol(invalidArgumentsSignal);
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 ENFILE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1954
	    case ENFILE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1955
		sym = @symbol(ENFILE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1956
		typ = @symbol(noResourcesSignal);
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 EMFILE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1960
	    case EMFILE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1961
		sym = @symbol(EMFILE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1962
		typ = @symbol(noResourcesSignal);
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 ENOTTY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1966
	    case ENOTTY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1967
		sym = @symbol(ENOTTY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1968
		typ = @symbol(inappropriateOperationSignal);
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 EFBIG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1972
	    case EFBIG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1973
		sym = @symbol(EFBIG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1974
		typ = @symbol(noResourcesSignal);
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 ENOSPC
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1978
	    case ENOSPC:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1979
		sym = @symbol(ENOSPC);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1980
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1981
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1982
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1983
#ifdef ESPIPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1984
	    case ESPIPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1985
		sym = @symbol(ESPIPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1986
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1987
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1988
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1989
#ifdef EROFS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1990
	    case EROFS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1991
		sym = @symbol(EROFS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1992
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1993
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1994
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1995
#ifdef EMLINK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1996
	    case EMLINK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1997
		sym = @symbol(EMLINK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1998
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1999
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2000
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2001
#ifdef EPIPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2002
	    case EPIPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2003
		sym = @symbol(EPIPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2004
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2005
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2006
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2007
#ifdef EDOM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2008
	    case EDOM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2009
		sym = @symbol(EDOM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2010
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2011
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2012
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2013
#ifdef ERANGE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2014
	    case ERANGE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2015
		sym = @symbol(ERANGE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2016
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2017
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2018
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2019
#ifdef EDEADLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2020
# if EDEADLK != EWOULDBLOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2021
	    case EDEADLK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2022
		sym = @symbol(EDEADLK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2023
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2024
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2025
# endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2026
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2027
#ifdef ENAMETOOLONG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2028
	    case ENAMETOOLONG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2029
		sym = @symbol(ENAMETOOLONG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2030
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2031
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2032
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2033
#ifdef ENOLCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2034
	    case ENOLCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2035
		sym = @symbol(ENOLCK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2036
		typ = @symbol(inappropriateOperationSignal);
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 ENOSYS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2040
	    case ENOSYS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2041
		sym = @symbol(ENOSYS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2042
		typ = @symbol(inappropriateOperationSignal);
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
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2046
	    case ENOTEMPTY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2047
		sym = @symbol(ENOTEMPTY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2048
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2049
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2050
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2051
#ifdef EILSEQ
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2052
	    case EILSEQ:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2053
		sym = @symbol(EILSEQ);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2054
		typ = @symbol(transferFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2055
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2056
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2057
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2058
	     * XPG3 errnos - defined on most systems
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2059
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2060
#ifdef ENOTBLK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2061
	    case ENOTBLK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2062
		sym = @symbol(ENOTBLK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2063
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2064
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2065
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2066
#ifdef ETXTBSY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2067
	    case ETXTBSY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2068
		sym = @symbol(ETXTBSY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2069
		typ = @symbol(inaccessibleSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2070
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2071
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2072
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2073
	     * some others
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2074
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2075
#ifdef EWOULDBLOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2076
	    case EWOULDBLOCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2077
		sym = @symbol(EWOULDBLOCK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2078
		typ = @symbol(notReadySignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2079
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2080
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2081
#ifdef ENOMSG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2082
	    case ENOMSG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2083
		sym = @symbol(ENOMSG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2084
		typ = @symbol(noDataSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2085
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2086
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2087
#ifdef ELOOP
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2088
	    case ELOOP:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2089
		sym = @symbol(ELOOP);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2090
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2091
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2092
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2093
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2094
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2095
	     * some stream errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2096
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2097
#ifdef ETIME
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2098
	    case ETIME:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2099
		sym = @symbol(ETIME);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2100
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2101
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2102
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2103
#ifdef ENOSR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2104
	    case ENOSR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2105
		sym = @symbol(ENOSR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2106
		typ = @symbol(noResourcesSignal);
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 ENOSTR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2110
	    case ENOSTR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2111
		sym = @symbol(ENOSTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2112
		typ = @symbol(inappropriateReferentSignal);
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 ECOMM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2116
	    case ECOMM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2117
		sym = @symbol(ECOMM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2118
		typ = @symbol(transferFaultSignal);
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 EPROTO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2122
	    case EPROTO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2123
		sym = @symbol(EPROTO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2124
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2125
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2126
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2127
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2128
	     * nfs errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2129
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2130
#ifdef ESTALE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2131
	    case ESTALE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2132
		sym = @symbol(ESTALE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2133
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2134
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2135
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2136
#ifdef EREMOTE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2137
	    case EREMOTE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2138
		sym = @symbol(EREMOTE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2139
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2140
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2141
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2142
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2143
	     * some networking errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2144
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2145
#ifdef EINPROGRESS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2146
	    case EINPROGRESS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2147
		sym = @symbol(EINPROGRESS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2148
		typ = @symbol(operationStartedSignal);
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 EALREADY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2152
	    case EALREADY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2153
		sym = @symbol(EALREADY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2154
		typ = @symbol(operationStartedSignal);
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 ENOTSOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2158
	    case ENOTSOCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2159
		sym = @symbol(ENOTSOCK);
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 EDESTADDRREQ
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2164
	    case EDESTADDRREQ:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2165
		sym = @symbol(EDESTADDRREQ);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2166
		typ = @symbol(underspecifiedSignal);
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 EMSGSIZE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2170
	    case EMSGSIZE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2171
		sym = @symbol(EMSGSIZE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2172
		typ = @symbol(rangeErrorSignal);
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 EPROTOTYPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2176
	    case EPROTOTYPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2177
		sym = @symbol(EPROTOTYPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2178
		typ = @symbol(wrongSubtypeForOperationSignal);
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 ENOPROTOOPT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2182
	    case ENOPROTOOPT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2183
		sym = @symbol(ENOPROTOOPT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2184
		typ = @symbol(unsupportedOperationSignal);
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 EPROTONOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2188
	    case EPROTONOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2189
		sym = @symbol(EPROTONOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2190
		typ = @symbol(unsupportedOperationSignal);
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 ESOCKTNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2194
	    case ESOCKTNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2195
		sym = @symbol(ESOCKTNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2196
		typ = @symbol(unsupportedOperationSignal);
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 EOPNOTSUPP
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2200
	    case EOPNOTSUPP:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2201
		sym = @symbol(EOPNOTSUPP);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2202
		typ = @symbol(inappropriateOperationSignal);
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 EPFNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2206
	    case EPFNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2207
		sym = @symbol(EPFNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2208
		typ = @symbol(unsupportedOperationSignal);
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 EAFNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2212
	    case EAFNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2213
		sym = @symbol(EAFNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2214
		typ = @symbol(unsupportedOperationSignal);
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 EADDRINUSE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2218
	    case EADDRINUSE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2219
		sym = @symbol(EADDRINUSE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2220
		typ = @symbol(existingReferentSignal);
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 EADDRNOTAVAIL
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2224
	    case EADDRNOTAVAIL:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2225
		sym = @symbol(EADDRNOTAVAIL);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2226
		typ = @symbol(noPermissionsSignal);
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 ETIMEDOUT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2230
	    case ETIMEDOUT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2231
		sym = @symbol(ETIMEDOUT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2232
		typ = @symbol(peerFaultSignal);
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 ECONNREFUSED
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2236
	    case ECONNREFUSED:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2237
		sym = @symbol(ECONNREFUSED);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2238
		typ = @symbol(peerFaultSignal);
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 ENETDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2242
	    case ENETDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2243
		sym = @symbol(ENETDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2244
		typ = @symbol(peerFaultSignal);
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 ENETUNREACH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2248
	    case ENETUNREACH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2249
		sym = @symbol(ENETUNREACH);
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 ENETRESET
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2254
	    case ENETRESET:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2255
		sym = @symbol(ENETRESET);
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;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2258
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2259
#ifdef ECONNABORTED
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2260
	    case ECONNABORTED:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2261
		sym = @symbol(ECONNABORTED);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2262
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2263
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2264
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2265
#ifdef ECONNRESET
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2266
	    case ECONNRESET:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2267
		sym = @symbol(ECONNRESET);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2268
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2269
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2270
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2271
#ifdef EISCONN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2272
	    case EISCONN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2273
		sym = @symbol(EISCONN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2274
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2275
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2276
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2277
#ifdef ENOTCONN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2278
	    case ENOTCONN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2279
		sym = @symbol(ENOTCONN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2280
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2281
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2282
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2283
#ifdef ESHUTDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2284
	    case ESHUTDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2285
		sym = @symbol(ESHUTDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2286
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2287
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2288
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2289
#ifdef EHOSTDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2290
	    case EHOSTDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2291
		sym = @symbol(EHOSTDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2292
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2293
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2294
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2295
#ifdef EHOSTUNREACH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2296
	    case EHOSTUNREACH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2297
		sym = @symbol(EHOSTUNREACH);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2298
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2299
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2300
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2301
#ifdef EDQUOT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2302
	    case EDQUOT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2303
		sym = @symbol(EDQUOT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2304
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2305
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2306
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2307
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2308
#ifdef ENOMEDIUM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2309
	    case ENOMEDIUM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2310
		sym = @symbol(ENOMEDIUM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2311
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2312
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2313
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2314
#ifdef EMEDIUMTYPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2315
	    case EMEDIUMTYPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2316
		sym = @symbol(EMEDIUMTYPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2317
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2318
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2319
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2320
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2321
	    default:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2322
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2323
	}
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2324
    }
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2325
%}.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2326
    holder := OSErrorHolder new.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2327
    holder errorSymbol:sym errorCategory:typ.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2328
    ^ holder
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2329
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2330
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2331
     OperatingSystem errorHolderForNumber:4
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2332
     self errorHolderForNumber:(self errorNumberFor:#EPERM)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2333
     self errorHolderForNumber:(self errorNumberFor:#EIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2334
     self errorHolderForNumber:(self errorNumberFor:#ENXIO)
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2335
     self errorHolderForNumber:(self errorNumberFor:#EOVERFLOW)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2336
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2337
!
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2338
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2339
errorNumberFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2340
    "given a symbolic error, return the numeric;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2341
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2342
     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
  2343
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2344
%{   /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2345
    OBJ sym = aSymbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2346
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2347
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2348
     * POSIX errnos - these should be defined
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 EPERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2351
    if (sym == @symbol(EPERM)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2352
	RETURN ( __MKSMALLINT(EPERM) );
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 ENOENT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2357
    if (sym == @symbol(ENOENT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2358
	RETURN ( __MKSMALLINT(ENOENT) );
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 ESRCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2363
    if (sym == @symbol(ESRCH)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2364
	RETURN ( __MKSMALLINT(ESRCH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2365
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2366
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2367
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2368
#ifdef EINTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2369
    if (sym == @symbol(EINTR)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2370
	RETURN ( __MKSMALLINT(EINTR) );
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 EIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2375
    if (sym == @symbol(EIO)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2376
	RETURN ( __MKSMALLINT(EIO) );
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 ENXIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2381
    if (sym == @symbol(ENXIO)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2382
	RETURN ( __MKSMALLINT(ENXIO) );
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 E2BIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2387
    if (sym == @symbol(E2BIG)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2388
	RETURN ( __MKSMALLINT(E2BIG) );
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 ENOEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2393
    if (sym == @symbol(ENOEXEC)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2394
	RETURN ( __MKSMALLINT(ENOEXEC) );
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 EBADF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2399
    if (sym == @symbol(EBADF)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2400
	RETURN ( __MKSMALLINT(EBADF) );
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 ECHILD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2405
    if (sym == @symbol(ECHILD)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2406
	RETURN ( __MKSMALLINT(ECHILD) );
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
#if defined(EAGAIN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2411
    if (sym == @symbol(EAGAIN)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2412
	RETURN ( __MKSMALLINT(EAGAIN) );
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 ENOMEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2417
    if (sym == @symbol(ENOMEM)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2418
	RETURN ( __MKSMALLINT(ENOMEM) );
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 EACCES
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2423
    if (sym == @symbol(EACCES)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2424
	RETURN ( __MKSMALLINT(EACCES) );
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 EFAULT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2429
    if (sym == @symbol(EFAULT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2430
	RETURN ( __MKSMALLINT(EFAULT) );
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 EBUSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2435
    if (sym == @symbol(EBUSY)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2436
	RETURN ( __MKSMALLINT(EBUSY) );
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 EXDEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2441
    if (sym == @symbol(EXDEV)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2442
	RETURN ( __MKSMALLINT(EXDEV) );
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 ENODEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2447
    if (sym == @symbol(ENODEV)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2448
	RETURN ( __MKSMALLINT(ENODEV) );
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 ENOTDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2453
    if (sym == @symbol(ENOTDIR)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2454
	RETURN ( __MKSMALLINT(ENOTDIR) );
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 EISDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2459
    if (sym == @symbol(EISDIR)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2460
	RETURN ( __MKSMALLINT(EISDIR) );
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 EINVAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2465
    if (sym == @symbol(EINVAL)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2466
	RETURN ( __MKSMALLINT(EINVAL) );
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 ENFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2471
    if (sym == @symbol(ENFILE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2472
	RETURN ( __MKSMALLINT(ENFILE) );
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 EMFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2477
    if (sym == @symbol(EMFILE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2478
	RETURN ( __MKSMALLINT(EMFILE) );
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 ENOTTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2483
    if (sym == @symbol(ENOTTY)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2484
	RETURN ( __MKSMALLINT(ENOTTY) );
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 EFBIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2489
    if (sym == @symbol(EFBIG)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2490
	RETURN ( __MKSMALLINT(EFBIG) );
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 ENOSPC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2495
    if (sym == @symbol(ENOSPC)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2496
	RETURN ( __MKSMALLINT(ENOSPC) );
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 ESPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
    if (sym == @symbol(ESPIPE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2502
	RETURN ( __MKSMALLINT(ESPIPE) );
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 EROFS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2507
    if (sym == @symbol(EROFS)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2508
	RETURN ( __MKSMALLINT(EROFS) );
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 EMLINK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2513
    if (sym == @symbol(EMLINK)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2514
	RETURN ( __MKSMALLINT(EMLINK) );
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 EPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2519
    if (sym == @symbol(EPIPE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2520
	RETURN ( __MKSMALLINT(EPIPE) );
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 EDOM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2525
    if (sym == @symbol(EDOM)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2526
	RETURN ( __MKSMALLINT(EDOM) );
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 ERANGE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2531
    if (sym == @symbol(ERANGE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2532
	RETURN ( __MKSMALLINT(ERANGE) );
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
#ifdef EDEADLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2537
    if (sym == @symbol(EDEADLK)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2538
	RETURN ( __MKSMALLINT(EDEADLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2539
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2540
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2541
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2542
#ifdef ENAMETOOLONG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2543
    if (sym == @symbol(ENAMETOOLONG)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2544
	RETURN ( __MKSMALLINT(ENAMETOOLONG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2545
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2546
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2547
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2548
#ifdef ENOLCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2549
    if (sym == @symbol(ENOLCK)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2550
	RETURN ( __MKSMALLINT(ENOLCK) );
3496
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
#endif
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 ENOSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2555
    if (sym == @symbol(ENOSYS)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2556
	RETURN ( __MKSMALLINT(ENOSYS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2557
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2558
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2559
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2560
#ifdef ENOTEMPTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2561
    if (sym == @symbol(ENOTEMPTY)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2562
	RETURN ( __MKSMALLINT(ENOTEMPTY) );
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 EEXIST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2567
    if (sym == @symbol(EEXIST)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2568
	RETURN ( __MKSMALLINT(EEXIST) );
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 EILSEQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2573
    if (sym == @symbol(EILSEQ)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2574
	RETURN ( __MKSMALLINT(EILSEQ) );
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
     * XPG3 errnos - defined on most systems
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 ENOTBLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2582
    if (sym == @symbol(ENOTBLK)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2583
	RETURN ( __MKSMALLINT(ENOTBLK) );
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 ETXTBSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
    if (sym == @symbol(ETXTBSY)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2589
	RETURN ( __MKSMALLINT(ETXTBSY) );
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2594
     * some others
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2595
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2596
#ifdef EWOULDBLOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2597
    if (sym == @symbol(EWOULDBLOCK)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2598
	RETURN ( __MKSMALLINT(EWOULDBLOCK) );
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2599
    }
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2600
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2601
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2602
#ifdef EOVERFLOW
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2603
    if (sym == @symbol(EOVERFLOW)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2604
	RETURN ( __MKSMALLINT(EOVERFLOW) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2605
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2606
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2607
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2608
#ifdef ENOMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
    if (sym == @symbol(ENOMSG)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2610
	RETURN ( __MKSMALLINT(ENOMSG) );
3496
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
#endif
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 ELOOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2615
    if (sym == @symbol(ELOOP)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2616
	RETURN ( __MKSMALLINT(ELOOP) );
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2621
     * some stream errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2622
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2623
#ifdef ETIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2624
    if (sym == @symbol(ETIME)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2625
	RETURN ( __MKSMALLINT(ETIME) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2626
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2627
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2628
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2629
#ifdef ENOSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2630
    if (sym == @symbol(ENOSR)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2631
	RETURN ( __MKSMALLINT(ENOSR) );
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 ENOSTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2636
    if (sym == @symbol(ENOSTR)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2637
	RETURN ( __MKSMALLINT(ENOSTR) );
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 ECOMM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2642
    if (sym == @symbol(ECOMM)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2643
	RETURN ( __MKSMALLINT(ECOMM) );
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 EPROTO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2648
    if (sym == @symbol(EPROTO)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2649
	RETURN ( __MKSMALLINT(EPROTO) );
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2654
     * nfs errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2655
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2656
#ifdef ESTALE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2657
    if (sym == @symbol(ESTALE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2658
	RETURN ( __MKSMALLINT(ESTALE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2659
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2660
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2661
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2662
#ifdef EREMOTE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2663
    if (sym == @symbol(EREMOTE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2664
	RETURN ( __MKSMALLINT(EREMOTE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2665
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2666
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2667
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
     * some networking errors
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 EINPROGRESS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2672
    if (sym == @symbol(EINPROGRESS)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2673
	RETURN ( __MKSMALLINT(EINPROGRESS) );
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 EALREADY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
    if (sym == @symbol(EALREADY)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2679
	RETURN ( __MKSMALLINT(EALREADY) );
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 ENOTSOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2684
    if (sym == @symbol(ENOTSOCK)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2685
	RETURN ( __MKSMALLINT(ENOTSOCK) );
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 EDESTADDRREQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2690
    if (sym == @symbol(EDESTADDRREQ)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2691
	RETURN ( __MKSMALLINT(EDESTADDRREQ) );
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 EMSGSIZE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
    if (sym == @symbol(EMSGSIZE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2697
	RETURN ( __MKSMALLINT(EMSGSIZE) );
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 EPROTOTYPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
    if (sym == @symbol(EPROTOTYPE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2703
	RETURN ( __MKSMALLINT(EPROTOTYPE) );
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 ENOPROTOOPT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2708
    if (sym == @symbol(ENOPROTOOPT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2709
	RETURN ( __MKSMALLINT(ENOPROTOOPT) );
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 EPROTONOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
    if (sym == @symbol(EPROTONOSUPPORT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2715
	RETURN ( __MKSMALLINT(EPROTONOSUPPORT) );
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 ESOCKTNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2720
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2721
	RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) );
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 EOPNOTSUPP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2726
    if (sym == @symbol(EOPNOTSUPP)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2727
	RETURN ( __MKSMALLINT(EOPNOTSUPP) );
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 EPFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2732
    if (sym == @symbol(EPFNOSUPPORT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2733
	RETURN ( __MKSMALLINT(EPFNOSUPPORT) );
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 EAFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2738
    if (sym == @symbol(EAFNOSUPPORT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2739
	RETURN ( __MKSMALLINT(EAFNOSUPPORT) );
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 EADDRINUSE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2744
    if (sym == @symbol(EADDRINUSE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2745
	RETURN ( __MKSMALLINT(EADDRINUSE) );
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 EADDRNOTAVAIL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
    if (sym == @symbol(EADDRNOTAVAIL)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2751
	RETURN ( __MKSMALLINT(EADDRNOTAVAIL) );
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 ETIMEDOUT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
    if (sym == @symbol(ETIMEDOUT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2757
	RETURN ( __MKSMALLINT(ETIMEDOUT) );
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 ECONNREFUSED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2762
    if (sym == @symbol(ECONNREFUSED)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2763
	RETURN ( __MKSMALLINT(ECONNREFUSED) );
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 ENETDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2768
    if (sym == @symbol(ENETDOWN)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2769
	RETURN ( __MKSMALLINT(ENETDOWN) );
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 ENETUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2774
    if (sym == @symbol(ENETUNREACH)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2775
	RETURN ( __MKSMALLINT(ENETUNREACH) );
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 ENETRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2780
    if (sym == @symbol(ENETRESET)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2781
	RETURN ( __MKSMALLINT(ENETRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2782
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2783
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2785
#ifdef ECONNABORTED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
    if (sym == @symbol(ECONNABORTED)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2787
	RETURN ( __MKSMALLINT(ECONNABORTED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2788
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2789
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2790
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2791
#ifdef ECONNRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
    if (sym == @symbol(ECONNRESET)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2793
	RETURN ( __MKSMALLINT(ECONNRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2794
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2795
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2796
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2797
#ifdef EISCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2798
    if (sym == @symbol(EISCONN)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2799
	RETURN ( __MKSMALLINT(EISCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2800
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2801
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2802
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2803
#ifdef ENOTCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2804
    if (sym == @symbol(ENOTCONN)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2805
	RETURN ( __MKSMALLINT(ENOTCONN) );
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2808
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
#ifdef ESHUTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2810
    if (sym == @symbol(ESHUTDOWN)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2811
	RETURN ( __MKSMALLINT(ESHUTDOWN) );
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2814
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
#ifdef EHOSTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
    if (sym == @symbol(EHOSTDOWN)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2817
	RETURN ( __MKSMALLINT(EHOSTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2818
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2819
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2820
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2821
#ifdef EHOSTUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
    if (sym == @symbol(EHOSTUNREACH)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2823
	RETURN ( __MKSMALLINT(EHOSTUNREACH) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2824
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2825
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2826
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2827
#ifdef EREMOTEIO
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2828
    if (sym == @symbol(EREMOTEIO)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2829
	RETURN ( __MKSMALLINT(EREMOTEIO) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2830
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2831
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2832
#ifdef EDQUOT
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2833
    if (sym == @symbol(EDQUOT)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2834
	RETURN ( __MKSMALLINT(EDQUOT) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2835
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2836
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2837
#ifdef ENOMEDIUM
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2838
    if (sym == @symbol(ENOMEDIUM)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2839
	RETURN ( __MKSMALLINT(ENOMEDIUM) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2840
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2841
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2842
#ifdef EMEDIUMTYPE
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2843
    if (sym == @symbol(EMEDIUMTYPE)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2844
	RETURN ( __MKSMALLINT(EMEDIUMTYPE) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2845
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2846
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2847
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2849
    ^ -1
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2850
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2851
    "
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2852
     self errorNumberFor:#EOVERFLOW
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2853
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2854
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2855
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2856
!UnixOperatingSystem class methodsFor:'executing OS commands-implementation'!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2858
exec:aCommandPath withArguments:argColl environment:environmentDictionary
7170
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  2859
    fileDescriptors:fdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  2860
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2861
    "Internal lowLevel entry for combined fork & exec;
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2862
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2863
     If fork is false (chain a command):
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2864
	 execute the OS command specified by the argument, aCommandPath, with
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2865
	 arguments in argArray (no arguments, if nil).
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2866
	 If successful, this method does not return and smalltalk is gone.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2867
	 If not successful, it does return.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2868
	 Normal use is with forkForCommand.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2869
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2870
     If fork is true (subprocess command execution):
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2871
	fork a child to do the above.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2872
	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
  2873
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7072
diff changeset
  2874
     fdColl contains the filedescriptors, to be used for the child (if fork is true).
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2875
	fdArray[1] = 15 -> use fd 15 as stdin.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2876
	If an element of the array is set to nil, the corresponding filedescriptor
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2877
	will be closed for the child.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2878
	fdArray[1] == StdIn for child
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2879
	fdArray[2] == StdOut for child
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2880
	fdArray[3] == StdErr for child
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2881
	on VMS, these must be channels as returned by createMailBox.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2882
	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
  2883
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2884
     If newPgrp is true, the subprocess will be established in a new process group.
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2885
	The processgroup will be equal to id.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2886
	newPgrp is not used on WIN32 and VMS systems.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2887
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2888
     environmentDictionary specifies environment variables which are passed differently from
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2889
     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
  2890
     key-value pairs for changed/added environment variables.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2891
     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
  2892
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2893
     Notice: this used to be two separate ST-methods; however, in order to use
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2894
	    vfork on some machines, it had to be merged into one, to avoid write
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2895
	    accesses to ST/X memory from the vforked-child.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2896
	    The code below only does read accesses."
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2897
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2898
    |envArray argArray fdArray dirName cnt|
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2899
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2900
    environmentDictionary size ~~ 0 ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2901
	envArray := Array new:environmentDictionary size.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2902
	cnt := 1.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2903
	environmentDictionary keysAndValuesDo:[:key :val |
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2904
	    val isNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2905
		envArray at:cnt put:(key, '=')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2906
	    ] ifFalse:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2907
		envArray at:cnt put:(key, '=', val)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2908
	    ].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2909
	    cnt := cnt + 1.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2910
	].
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2911
    ].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2912
    argColl notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2913
	argArray := argColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2914
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2915
    fdColl notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2916
	fdArray := fdColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2917
    ].
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2918
    aDirectory notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2919
	dirName := aDirectory asFilename name
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2920
    ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2921
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2922
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2923
    char **argv;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2924
    int nargs, i, id;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2925
    OBJ arg;
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2926
    extern char **environ;
3571
9090dc66a427 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
  2927
    char **_env, **_nEnv;
3801
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2928
#ifndef __isArrayLike
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2929
# define __isArrayLike __isArray
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2930
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2931
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2932
    if (__isString(aCommandPath) &&
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2933
	((argArray == nil) || __isArrayLike(argArray)) &&
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2934
	((fdArray == nil) || __isArrayLike(fdArray))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2935
    ) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2936
	nargs = argArray == nil ? 0 : __arraySize(argArray);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2937
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2938
	if (argv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2939
	    int nOldEnv, nNewEnv;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2940
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2941
	    for (i=0; i < nargs; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2942
		arg = __ArrayInstPtr(argArray)->a_element[i];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2943
		if (__isString(arg)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2944
		    argv[i] = (char *) __stringVal(arg);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2945
		} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2946
		    argv[i] = "";
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2947
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2948
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2949
	    argv[i] = NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2950
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2951
	    /*
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2952
	     * number of new items in environment ..
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2953
	     */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2954
	    nNewEnv = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2955
	    if ((envArray != nil) && __isArrayLike(envArray)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2956
		nNewEnv = __arraySize(envArray);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2957
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2958
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2959
	    if (nNewEnv == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2960
		_nEnv = environ;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2961
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2962
		_env = environ;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2963
		/*
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2964
		 * get size of environment
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2965
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2966
		nOldEnv = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2967
		if (_env) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2968
		    while (*_env) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2969
			nOldEnv++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2970
			_env++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2971
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2972
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2973
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2974
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2975
		 * generate a new environment
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2976
		 * I have not found a spec which defines if
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2977
		 * items at the end overwrite previous definitions,
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2978
		 * or if the first encountered definition is valid.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2979
		 * To be prepared for any case, simply add the new definitions
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2980
		 * at both ends - that should do it in any case.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2981
		 * Someone with more know-how may want to fix this.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2982
		 * getenv() searches for the first entry.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2983
		 * But maybe someone creates a Dictionary from the environment.
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2984
		 * In this case the last entry would overwrite previous entries.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2985
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2986
		_nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2987
		if (_nEnv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2988
		    char **eO, **eN;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2989
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2990
		    eN = _nEnv;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2991
		    if (nNewEnv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2992
			/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2993
			 * add new items at the front ...
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2994
			 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2995
			int i;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2996
			OBJ *t;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2997
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2998
			for (i=0, t = __arrayVal(envArray);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2999
			     i < __arraySize(envArray);
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3000
			     i++, t++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3001
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3002
			    if (__isString(*t)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3003
				*eN++ = (char *)__stringVal(*t);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3004
			    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3005
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3006
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3007
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3008
		    if (nOldEnv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3009
			/*
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3010
			 * append old environment
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3011
			 */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3012
			for (eO = environ; *eO; *eN++ = *eO++)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3013
			    continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3014
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3015
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3016
		    if (nNewEnv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3017
			/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3018
			 * append new items again at the end
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3019
			 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3020
			for (eO = _nEnv, i=0; i<nNewEnv; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3021
			    *eN++ = *eO++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3022
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3023
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3024
		    *eN = NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3025
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3026
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3027
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3028
	    if (doFork == true) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3029
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3030
		 * fork a subprocess.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3031
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3032
		int nfd;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3033
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3034
		nfd = fdArray == nil ? 0 : __arraySize(fdArray);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3035
		id = FORK ();
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3036
		if (id == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3037
		    /*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3038
		    ** In child.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3039
		    ** first: dup filedescriptors.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3040
		    */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3041
		    for (i = 0; i < nfd; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3042
			OBJ fd;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3043
			int rslt;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3044
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3045
			fd = __arrayVal(fdArray)[i];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3046
			if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3047
			    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3048
				rslt = dup2(__intVal(fd), i);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3049
			    } while ((rslt < 0) && (errno == EINTR));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3050
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3051
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3052
		    /*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3053
		    ** Second: close descriptors
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3054
		    **         marked as unwanted
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3055
		    ** (extra loop to allow duping of low filedescriptor numbers to
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3056
		    **  higher fd numbers)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3057
		    */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3058
		    for (i = 0; i < nfd; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3059
			if (__arrayVal(fdArray)[i] == nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3060
			    close(i);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3061
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3062
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3063
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3064
		    /*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3065
		    ** third: close all filedescriptors larger
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3066
		    ** then the explicitely closed or duped
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3067
		    ** filedescriptors
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3068
		    */
7072
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3069
#ifndef OPEN_MAX
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3070
# define OPEN_MAX       256
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3071
#endif
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3072
		    for ( ;i < OPEN_MAX; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3073
			close(i);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3074
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3075
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3076
		    if (newPgrp == true) {
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3077
#ifndef NEXT
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3078
			setsid();
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3079
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3080
#if defined(TIOCSCTTY)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3081
			ioctl(0, TIOCSCTTY, 0) ;
3561
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3082
#endif
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3083
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3084
#if defined(TIOCSPGRP)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3085
			{
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3086
			    int pgrp = getpid();
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3087
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3088
			    ioctl(0, TIOCSPGRP, (char *)&pgrp);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3089
			}
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3090
#endif
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3091
#if defined(_POSIX_JOB_CONTROL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3092
			(void) setpgid(0, 0);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3093
#else
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3094
# if defined(BSD) || defined(LINUX)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3095
			(void) setpgrp(0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3096
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3097
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3098
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3099
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3100
		    if (dirName != nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3101
			chdir(__stringVal(dirName));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3102
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3103
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3104
		    execve(__stringVal(aCommandPath), argv, _nEnv);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3105
		    /* reached if aCommandPathh cannot be executed */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3106
		    _exit(127);                 /* POSIX 2 compatible exit value */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3107
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3108
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3109
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3110
		 * no subprocess (i.e. transfer to another program)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3111
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3112
		if (dirName != nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3113
		    chdir(__stringVal(dirName));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3114
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3115
		execve(__stringVal(aCommandPath), argv, _nEnv);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3116
		/*
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3117
		 * reached if command-path cannot be executed
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3118
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3119
		id = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3120
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3121
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3122
	    if (nNewEnv && (_nEnv != NULL)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3123
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3124
		 * free new environment stuff
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3125
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3126
		free(_nEnv);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3127
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3128
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3129
	    free(argv);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3130
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3131
	    /*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3132
	     * In parent: succes or failure
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3133
	     */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3134
	    if (id == -1) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3135
		RETURN (nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3136
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3137
		RETURN (__MKSMALLINT(id));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3138
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3139
	}
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3140
    }
3496
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
     path-argument not string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
     or argArray not an array/nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
     or malloc failed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
     or not supported by OS
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3152
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3153
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
     id == 0 ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3155
	'I am the child'.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3156
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3157
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3158
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3159
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3162
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3163
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
     id == 0 ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3165
	'I am the child'.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3166
	OperatingSystem
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3167
	   exec:'/bin/sh'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3168
	   withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3169
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3170
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3171
     id printNL.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3172
     (Delay forSeconds:3.5) wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3173
     'killing ...' printNL.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3174
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3175
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3176
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3177
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3179
fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3180
    "fork a new (HEAVY-weight) unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3181
     Not supported with MSDOS & VMS systems.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3182
     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
  3183
     lightweight smalltalk processes. This method will return
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3184
     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
  3185
     unix-process-id) to the parent (original) process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3186
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3187
     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
  3188
     #startProcess: and #executCommand: for higher level interfaces."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3190
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3191
    int pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3192
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3193
    pid = fork();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3194
    RETURN ( __MKUINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3195
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3196
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3197
    "/ not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3198
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3199
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3200
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3201
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3202
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3203
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3204
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3205
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3206
     id == 0 ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3207
	'I am the child process' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3208
	OperatingSystem exit
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3209
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3210
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3211
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3212
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3213
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3214
    errorTo:anExternalErrStream auxFrom:anAuxiliaryStream
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3215
    environment:anEvironmentDictionary inDirectory:dir
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3216
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3217
    "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
  3218
     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
  3219
     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
  3220
     '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
  3221
     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
  3222
     each may be nil.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3223
     Return the processId if successful, nil otherwise.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3224
     Use #monitorPid:action: for synchronization and exec status return,
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3225
     or #killProcess: to stop it."
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
    |nullStream in out err shellAndArgs rslt auxFd|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3228
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3229
    aCommandString isNil ifTrue:[^ nil].
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
    (in := anExternalInStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3232
	nullStream := Filename nullDevice readWriteStream.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3233
	in := nullStream.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3234
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3235
    (out := anExternalOutStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3236
	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3237
	out := nullStream.
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
    (err := anExternalErrStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3240
	err := out
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3241
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3242
    anAuxiliaryStream notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3243
	auxFd := anAuxiliaryStream fileDescriptor
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
    shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3247
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3248
    rslt := self
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3249
	exec:(shellAndArgs at:1)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3250
	withArguments:(shellAndArgs at:2)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3251
	environment:anEvironmentDictionary
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3252
	fileDescriptors:(Array with:in fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3253
			       with:out fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3254
			       with:err fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3255
			       with:auxFd)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3256
	fork:true
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3257
	newPgrp:true "/ false
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3258
	inDirectory:dir.
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
    nullStream notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3261
	nullStream close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3262
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3263
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3264
    ^ rslt
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
    "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
  3267
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3268
     OperatingSystem executeCommand:'ls -l > out'.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3269
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3270
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3271
    "non-blocking (lower prio threads continue):
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3272
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3273
     |in out err pid sema|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3274
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3275
     in := 'out' asFilename readStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3276
     out := 'out2' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3277
     err := 'err' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3278
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3279
     sema := Semaphore new.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3280
     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
  3281
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3282
     The following will no longer work. monitorPid has disappeared
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3283
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3284
     pid notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3285
	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3286
     ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3287
     in close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3288
     out close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3289
     err close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3290
     sema wait.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3291
     Transcript showCR:'finished'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3292
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3293
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3294
    "Modified: / 21.3.1997 / 10:04:35 / dq"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3295
    "Modified: / 15.7.1997 / 16:03:51 / stefan"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3296
    "Modified: / 5.6.1998 / 19:03:51 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3297
    "Created: / 12.11.1998 / 14:39:20 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3298
! !
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3299
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3300
!UnixOperatingSystem class methodsFor:'executing OS commands-queries'!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3301
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3302
commandAndArgsForOSCommand:aCommandString
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3303
    "get a shell and shell arguments for command execution"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3304
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3305
    |shell args|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3306
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3307
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3308
    "/ '/bin/sh -c <command>'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3309
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3310
    shell := '/bin/sh'.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3311
    args := Array with:'sh' with:'-c' with:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3312
    ^ Array with:shell with:args
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3313
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3314
    "Modified: / 20.1.1998 / 16:57:19 / md"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3315
    "Modified: / 5.6.1998 / 17:40:48 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3316
!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3317
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3318
pathOfCommand:aCommand
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3319
    "find where aCommand's executable file is;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3320
     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
  3321
     return nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3322
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3323
    |path f fExt|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3324
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3325
    aCommand asFilename isAbsolute ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3326
	^ aCommand
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3327
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3328
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3329
    path := self getEnvironment:'PATH'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3330
    path notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3331
	(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3332
	    path isEmpty ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3333
		f := aCommand asFilename
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3334
	    ] ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3335
		f := path asFilename construct:aCommand.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3336
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3337
	    self executableFileExtensions do:[:ext |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3338
		ext notEmpty ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3339
		    fExt := (f pathName , ext) asFilename.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3340
		] ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3341
		    fExt := f.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3342
		].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3343
		fExt isExecutable ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3344
		    ^ fExt pathName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3345
		].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3346
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3347
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3348
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3349
    ^ nil
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
    "unix:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3352
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3353
     OperatingSystem pathOfCommand:'fooBar'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3354
     OperatingSystem pathOfCommand:'ls'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3355
     OperatingSystem pathOfCommand:'cvs'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3356
     OperatingSystem pathOfCommand:'stx'
3496
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
    "windows:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3359
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3360
     OperatingSystem pathOfCommand:'windbg'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3361
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3362
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3363
    "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
  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
!UnixOperatingSystem class methodsFor:'file access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3367
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
closeFd:anInteger
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3369
    "low level close of a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3370
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
     if (__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3373
	if (@global(ExternalStream:FileOpenTrace) == true) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3374
	    fprintf(stderr, "close [UnixOp] fd=%d\n", __intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3375
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3376
	close(__intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3377
	RETURN(self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3378
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3379
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3380
     ^ self primitiveFailed.
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3381
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3382
    "
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3383
     10 to:400 do:[:fd | OperatingSystem closeFd:fd]
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3384
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3385
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3386
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3387
copyFromFd:inFd toFd:outFd startIndex:startIdx count:count
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3388
    "directly copy from one Fd to another (if supported by the OS)"
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
%{
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3391
#if defined(HAS_SENDFILE)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3392
     if (__isSmallInteger(inFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3393
      && __isSmallInteger(outFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3394
      && __isSmallInteger(startIdx)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3395
      && __isSmallInteger(count)) {
8337
1168b3ff3cdc Remove unspecific debug printf
Stefan Vogel <sv@exept.de>
parents: 8307
diff changeset
  3396
        int nWritten;
1168b3ff3cdc Remove unspecific debug printf
Stefan Vogel <sv@exept.de>
parents: 8307
diff changeset
  3397
1168b3ff3cdc Remove unspecific debug printf
Stefan Vogel <sv@exept.de>
parents: 8307
diff changeset
  3398
        nWritten = sendfile(__intVal(outFd), __intVal(inFd), __intVal(startIdx), __intVal(count));
1168b3ff3cdc Remove unspecific debug printf
Stefan Vogel <sv@exept.de>
parents: 8307
diff changeset
  3399
        if (nWritten < 0) {
8496
51f37676649e save LastErrorCode from sendto()
Stefan Vogel <sv@exept.de>
parents: 8490
diff changeset
  3400
            @global(LastErrorNumber) = __MKSMALLINT(errno);
8337
1168b3ff3cdc Remove unspecific debug printf
Stefan Vogel <sv@exept.de>
parents: 8307
diff changeset
  3401
        }
1168b3ff3cdc Remove unspecific debug printf
Stefan Vogel <sv@exept.de>
parents: 8307
diff changeset
  3402
        RETURN (__MKSMALLINT(nWritten));
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3403
     }
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3404
#endif
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3405
%}.
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3406
    ^ 0 "/ not supported
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3407
!
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3408
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3409
createDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3410
    "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
  3411
     path, or relative to the current directory.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3412
     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
  3413
     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
  3414
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3415
    "/ if it already exists this is ok
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
    (self isDirectory:aPathName) ifTrue:[^ true].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3418
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3419
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3420
    if (__isString(aPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3421
	int ret;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3422
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3423
	ret = mkdir(__stringVal(aPathName), 0755);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3424
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3425
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3426
	    RETURN (false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3427
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3428
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3429
      }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3430
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3431
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3432
"/    self isUNIXlike ifTrue:[
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3433
"/      ^ self executeCommand:('mkdir 2>/dev/null ', newPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3434
"/    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3435
"/    ^ self executeCommand:('mkdir ', newPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3436
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3437
    self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3438
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3439
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3440
     OperatingSystem createDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3441
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3442
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3443
    "Modified: 20.12.1995 / 11:24:13 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3444
    "Modified: 29.6.1996 / 14:06:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3445
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3446
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3447
createFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3448
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3449
    ^ self open:pathName attributes:#(O_RDWR O_APPEND O_CREAT) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3450
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3451
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3452
createFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3453
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3454
    ^ 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
  3455
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3456
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3457
createHardLinkFrom:oldPath to:newPath
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3458
    "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
  3459
     Return true if successful, false if not."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3460
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3461
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3462
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3463
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3464
    if (__isString(oldPath) && __isString(newPath)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3465
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3466
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3467
	    ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3468
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3469
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3470
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3471
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3472
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3473
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3474
	RETURN (true);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3475
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3476
%}.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3477
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3478
    "/ bad argument(s) given
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3479
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3480
    ^ self primitiveFailed
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3481
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3482
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3483
     OperatingSystem linkFile:'foo' to:'bar'
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3484
    "
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
createSymbolicLinkFrom:oldPath to:newPath
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3488
    "make a symbolic link for 'newPath' to the file 'oldPath'.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3489
     The link will be a soft (symbolic) link.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3490
     Return true if successful, false if not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3491
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3492
%{
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3493
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3494
    int ret;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3495
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3496
    if (__isString(oldPath) && __isString(newPath)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3497
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3498
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3499
	    ret = symlink((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3500
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3501
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3502
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3503
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3504
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3505
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3506
	RETURN (true);
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3507
    }
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3508
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3509
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3510
    (oldPath isString not or:[newPath isString not]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3511
	"/
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3512
	"/ bad argument(s) given
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3513
	"/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3514
	^ self primitiveFailed
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3517
    "/
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3518
    "/ 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
  3519
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3520
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3521
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3522
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3523
     OperatingSystem symbolicLinkFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3524
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3525
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3526
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3527
open:path attributes:attributes mode:modeInteger
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3528
    "open a file, return an os specific fileHandle.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3529
     openmode is a symbol defining the way to open
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3530
     valid modes are:
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3531
	#O_RDONLY
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3532
	#O_RDWR
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3533
	#O_WRONLY
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3534
	#O_CREAT
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3535
	#O_APPEND
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3536
	#O_SYNC
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3537
	#O_LARGEFILE
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3538
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3539
     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
  3540
     which is proprietrary to the operatingSystem."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3541
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3542
    |error fileDescriptor|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3543
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3544
%{
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3545
    OBJ *ap;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3546
    int nAttributes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3547
    int fd;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3548
    int mode, openFlags = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3549
    int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3550
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3551
    if (!__isString(path)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3552
	error = @symbol(badArgument1);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3553
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3554
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3555
    if (!__isArray(attributes)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3556
	error = @symbol(badArgument2);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3557
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3558
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3559
    if (modeInteger == nil) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3560
	mode = 0644;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3561
    } else if (__isSmallInteger(modeInteger)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3562
	mode = __intVal(modeInteger);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3563
    } else {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3564
	error = @symbol(badArgument3);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3565
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3566
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3567
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3568
    nAttributes = __arraySize(attributes);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3569
    for (n = 0, ap = __arrayVal(attributes); n < nAttributes; n++) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3570
	OBJ attribute = ap[n];
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3571
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3572
	if (attribute == @symbol(O_RDONLY)) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3573
	    openFlags |= O_RDONLY;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3574
	} else if (attribute == @symbol(O_RDWR)) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3575
	    openFlags |= O_RDWR;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3576
	} else if (attribute == @symbol(O_WRONLY)) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3577
	    openFlags |= O_WRONLY;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3578
	} else if (attribute == @symbol(O_CREAT)) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3579
	    openFlags |= O_CREAT;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3580
	} else if (attribute == @symbol(O_APPEND)) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3581
	    openFlags |= O_APPEND;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3582
	} else if (attribute == @symbol(O_EXCL)) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3583
	    openFlags |= O_EXCL;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3584
	} else if (attribute == @symbol(O_TRUNC)) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3585
	    openFlags |= O_TRUNC;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3586
	} else if (attribute == @symbol(O_LARGEFILE)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3587
#ifdef O_LARGEFILE
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3588
	    openFlags |= O_LARGEFILE;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3589
#else
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3590
	    error = @symbol(badArgument2);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3591
	    goto err;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3592
#endif
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3593
	} else if (attribute == @symbol(O_SYNC)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3594
#ifdef O_SYNC
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3595
	    openFlags |= O_SYNC;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3596
#else
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3597
	    error = @symbol(badArgument2);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3598
	    goto err;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3599
#endif
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3600
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3601
    }
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
#if defined(O_NONBLOCK)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3604
    openFlags |= O_NONBLOCK;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  3605
#elif defined(O_NDELAY)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3606
    openFlags |= O_NDELAY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3607
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3608
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3609
again:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3610
    fd = open((char *) __stringVal(path), openFlags, mode);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3611
    if (fd < 0) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3612
	if (errno == EINTR) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3613
	    __HANDLE_INTERRUPTS__;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3614
	    goto again;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3615
	} else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3616
	    error = __mkSmallInteger(errno);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3617
	    goto err;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3618
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3619
    }
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  3620
    fileDescriptor = __mkSmallInteger(fd);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3621
err:;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3622
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3623
    ^ fileDescriptor notNil ifTrue:[
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3624
	FileDescriptorHandle for:fileDescriptor.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3625
    ] ifFalse:[
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3626
	(self errorHolderForNumber:error) reportError
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3627
    ].
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3628
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3629
    "
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3630
	self open:'/etc/hosts' attributes:#(O_RDONLY) mode:nil
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3631
	self open:'/tmp/xxzz' attributes:#(O_RDWR O_CREAT) mode:8r611
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3632
	self open:'/etc/passwd' attributes:#(O_RDWR) mode:nil
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3633
	self open:'/no one knows this file' attributes:#(O_RDONLY) mode:nil
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  3634
	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
  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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3638
openFileForAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3639
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3640
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3643
openFileForRead:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3644
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3645
    ^ self open:pathName attributes:#(O_RDONLY) mode:nil
6301
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3648
openFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3649
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3650
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3653
openFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3654
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3655
    ^ self open:pathName attributes:#(O_RDWR)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3656
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3657
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3658
openFileForWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3659
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3660
    ^ self open:pathName attributes:#(O_WRONLY)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3661
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3662
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3663
recursiveCopyDirectory:sourcePathName to:destination
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3664
    "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
  3665
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3666
7025
b172587b049b be careful with files with spaces in them (in recursiveRemove)
Claus Gittinger <cg@exept.de>
parents: 7003
diff changeset
  3667
    ^ self executeCommand:('cp -rf "' , sourcePathName, '" "', destination , '"')
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3668
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3669
    "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
  3670
!
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
recursiveRemoveDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3673
    "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
  3674
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3675
7025
b172587b049b be careful with files with spaces in them (in recursiveRemove)
Claus Gittinger <cg@exept.de>
parents: 7003
diff changeset
  3676
    ^ self executeCommand:('rm -rf "' , fullPathName , '"')
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3677
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3678
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3679
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3680
     OperatingSystem recursiveRemoveDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3681
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3682
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3683
    "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
  3684
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3685
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3686
removeDirectory:fullPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3687
    "remove the directory named 'fullPathName'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3688
     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
  3689
     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
  3690
     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
  3691
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3692
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3693
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3694
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3695
    if (__isString(fullPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3696
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3697
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3698
	    ret = rmdir((char *) __stringVal(fullPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3699
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3700
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3701
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3702
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3703
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3704
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3705
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3706
    }
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
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3709
    "/ either not a string argument,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3710
    "/ or not supported by OS
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
    ^ self primitiveFailed
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3715
     OperatingSystem createDirectory:'foo'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3716
     OperatingSystem removeDirectory:'foo'
3496
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3720
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3721
removeFile:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3722
    "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
  3723
     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
  3724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3725
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3726
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3728
    if (__isString(fullPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3729
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3730
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3731
	    ret = unlink((char *) __stringVal(fullPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3732
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3733
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3734
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3735
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3736
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3737
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3738
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3739
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3740
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3741
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3742
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3743
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3744
renameFile:oldPath to:newPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3745
    "rename the file 'oldPath' to 'newPath'.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3746
     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
  3747
     correct for the OS used - therefore, this should not be called
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3748
     directlt. Instead, use Filename protocol to rename; this cares for
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3749
     any invalid names.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3750
     Returns true if successful, false if not"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3751
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3752
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3753
    int ret, eno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3755
    if (__isString(oldPath) && __isString(newPath)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3756
#if defined(HAS_RENAME)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3757
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3758
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3759
	    ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3760
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3761
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3762
#else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3763
	ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3764
	if (ret >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3765
	    ret = unlink((char *) __stringVal(oldPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3766
	    if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3767
		eno = errno;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3768
		unlink((char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3769
		errno = eno;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3770
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3771
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3772
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3773
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3774
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3775
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3776
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3777
	RETURN (true);
3496
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3781
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3782
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3783
     OperatingSystem renameFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3784
    "
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3787
truncateFile:aPathName to:newSize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3788
    "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
  3789
     This may not be supported on all architectures.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3790
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3791
     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
  3792
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3793
%{
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3794
#if defined(HAS_TRUNCATE) || defined(HAS_FTRUNCATE)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3795
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3796
    off_t truncateSize;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3797
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3798
    if (!__isStringLike(aPathName))
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3799
	goto getOutOfHere;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3800
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3801
    if (__isSmallInteger(newSize)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3802
	truncateSize = __intVal(newSize);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3803
	if (truncateSize < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3804
	    goto getOutOfHere;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3805
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3806
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3807
	truncateSize = __signedLongIntVal(newSize);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3808
	if (truncateSize < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3809
	    goto getOutOfHere;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3810
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3811
	if (truncateSize == 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3812
	    if (sizeof(truncateSize) == 8) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3813
		if (__signedLong64IntVal(newSize, &truncateSize) == 0 || truncateSize < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3814
		    goto getOutOfHere;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3815
		}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3816
	    } else {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3817
		goto getOutOfHere;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3818
	    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3819
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3820
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3821
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3822
#if defined(HAS_TRUNCATE)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3823
	__BEGIN_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3824
	do {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3825
	    ret = truncate((char *) __stringVal(aPathName), truncateSize);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3826
	} while (ret < 0 && errno == EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3827
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3828
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3829
# ifdef HAS_FTRUNCATE
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3830
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3831
	int fd;
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
	do {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3834
	    fd = open((char *) __stringVal(aPathName), 2);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3835
	} while (fd < 0 && errno == EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3836
	if (fd < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3837
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3838
	    RETURN ( false );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3839
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3840
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3841
	ret = ftruncate(fd, truncateSize);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3842
	close(fd);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3843
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3844
# endif /* HAS_FTRUNCATE */
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3845
#endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3846
    if (ret < 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3847
	@global(LastErrorNumber) = __MKSMALLINT(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3848
	RETURN ( false );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3849
    }
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3850
    RETURN (true);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3851
getOutOfHere:;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3852
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3853
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3854
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3855
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3856
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3857
!UnixOperatingSystem class methodsFor:'file access rights'!
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
accessMaskFor:aSymbol
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3860
    "return the access bits mask for numbers as returned by
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3861
     OperatingSystem>>accessModeOf:
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3862
     and expected by OperatingSystem>>changeAccessModeOf:to:.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3863
     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
  3864
     (never hardcode 8rxxx into your code)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3866
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3867
#   ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3868
    /* posix systems should define these ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3869
#    define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3870
#    define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3871
#    define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3872
#    define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3873
#    define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3874
#    define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3875
#    define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3876
#    define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3877
#    define S_IXOTH 0001
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
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3880
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3881
    if (aSymbol == @symbol(readUser)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3882
	RETURN ( __MKSMALLINT(S_IRUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3883
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3884
    if (aSymbol == @symbol(writeUser)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3885
	RETURN ( __MKSMALLINT(S_IWUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3886
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3887
    if (aSymbol == @symbol(executeUser)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3888
	RETURN ( __MKSMALLINT(S_IXUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3889
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3890
    if (aSymbol == @symbol(readGroup)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3891
	RETURN ( __MKSMALLINT(S_IRGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3892
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3893
    if (aSymbol == @symbol(writeGroup)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3894
	RETURN ( __MKSMALLINT(S_IWGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3895
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3896
    if (aSymbol == @symbol(executeGroup)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3897
	RETURN ( __MKSMALLINT(S_IXGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3898
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3899
    if (aSymbol == @symbol(readOthers)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3900
	RETURN ( __MKSMALLINT(S_IROTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3901
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3902
    if (aSymbol == @symbol(writeOthers)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3903
	RETURN ( __MKSMALLINT(S_IWOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3904
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3905
    if (aSymbol == @symbol(executeOthers)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3906
	RETURN ( __MKSMALLINT(S_IXOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3907
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3908
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3909
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3910
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3911
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3912
     OperatingSystem accessMaskFor:#readUser
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3913
    "
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3916
accessModeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3917
    "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
  3918
     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
  3919
     Notice that the returned number is OS dependent - use the
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3920
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3921
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3922
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3923
     this could have been implemented as:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3924
	(self infoOf:aPathName) at:#mode
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3925
     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
  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
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3929
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3930
    int ret;
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
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3933
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3934
	printf("stat on '%s' for accessMode\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3935
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3936
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3937
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3938
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3939
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3940
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3941
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3942
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3943
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3944
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3945
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3946
	RETURN ( __MKSMALLINT(buf.st_mode & 0777) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3947
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3948
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3949
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3950
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3951
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3952
    (OperatingSystem accessModeOf:'/') printStringRadix:8
3496
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
!
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
changeAccessModeOf:aPathName to:modeBits
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3957
    "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
  3958
     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
  3959
     independent. Return true if changed,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3960
     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
  3961
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3962
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3963
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3964
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3965
    if (__isString(aPathName) && __isSmallInteger(modeBits)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3966
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3967
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3968
	    ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3969
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3970
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3971
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3972
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3973
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3974
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3975
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3976
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3977
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3978
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3979
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3980
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3981
!UnixOperatingSystem class methodsFor:'file locking'!
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
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3984
   "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
  3985
    (such as returned by ExternalStream>>fileDescriptor).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3986
    On some systems, only advisory locks are available -
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3987
    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
  3988
    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
  3989
    (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
  3990
    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
  3991
    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
  3992
    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
  3993
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3994
    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
  3995
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3996
    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
  3997
    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
  3998
    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
  3999
    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
  4000
    argument."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4002
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4003
    if (__isSmallInteger(aFileDescriptor)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4004
	int fd = __intVal(aFileDescriptor);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4005
	int lockArg;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4006
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4007
	/*
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4008
	 * claus: sigh - each one has a different interface ...
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4009
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4010
#if defined(F_SETLK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4011
	{
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4012
	    /*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4013
	     * new fcntl(SETLK) interface;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4014
	     * available on SYSV4 and Linux
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4015
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4016
	    struct flock flock;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4017
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4018
	    if (isSharedReadLock == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4019
		flock.l_type = F_RDLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4020
	    } else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4021
		flock.l_type = F_WRLCK;
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
	    flock.l_whence = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4024
	    flock.l_start = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4025
	    flock.l_len = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4026
	    lockArg = F_SETLK;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4027
# if defined(F_SETLKW)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4028
	    if (blockIfLocked == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4029
		lockArg = F_SETLKW;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4030
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4031
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4032
	    if (fcntl(fd, lockArg, &flock) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4033
		RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4034
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4035
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4036
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4037
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4038
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4039
# if defined(LOCK_EX) && defined(LOCK_UN)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4040
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4041
	 * BSD 4.3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4042
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4043
	lockArg = LOCK_EX;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4044
#  if defined(LOCK_SH)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4045
	if (isSharedReadLock == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4046
	    lockArg = LOCK_SH
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4047
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4048
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4049
#  if defined(LOCK_NB)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4050
	if (blockIfLocked == false) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4051
	    lockArg |= LOCK_NB;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4052
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4053
#  endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4054
	if (flock(fd, lockArg) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4055
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4056
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4057
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4058
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4059
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4060
#  if defined(F_LOCK) && defined(F_UNLOCK)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4061
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4062
	 * SYSV3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4063
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4064
	if (lockf(fd, F_LOCK, 0) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4065
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4066
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4067
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4068
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4069
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4070
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4071
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4072
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4073
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4074
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4075
supportsFileLinks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4076
    "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
  4077
     Typically, only unix returns true here."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4078
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4079
    ^ true
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4080
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4081
    "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
  4082
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4083
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4084
supportsFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4085
    "return true, if the OS supports file locking"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4086
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4087
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4088
#if defined(F_SETLK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4089
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4090
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4091
# if defined(LOCK_EX) && defined(LOCK_UN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4092
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4093
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4094
#  if defined(F_LOCK) && defined(F_UNLOCK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4095
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4096
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4097
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4098
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4099
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4100
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4101
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4102
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4103
     OperatingSystem supportsFileLocks
3496
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
!
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
supportsNonBlockingFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4108
    "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
  4109
     (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
  4110
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4111
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4112
#if defined(F_SETLK) && defined(F_SETLKW)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4113
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4114
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4115
# 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
  4116
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4117
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4118
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4119
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4120
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4121
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4122
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4123
     OperatingSystem supportsNonBlockingFileLocks
3496
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
!
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
supportsSharedLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4128
    "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
  4129
     file locking."
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
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4132
#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
  4133
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4134
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4135
# 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
  4136
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4137
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4138
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4139
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4140
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4141
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4142
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4143
     OperatingSystem supportsNonBlockingFileLocks
3496
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
!
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
unlockFD:aFileDescriptor
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4148
    "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
  4149
     which was previously aquired by #lockFD:.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4150
     Return false, if the unlock failed
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4151
     (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
  4152
      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
  4153
     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
  4154
     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
  4155
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4156
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4157
    if (__isSmallInteger(aFileDescriptor)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4158
	int fd = __intVal(aFileDescriptor);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4159
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4160
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4161
	 * claus: sigh - each one has a different interface ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4162
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4163
#if defined(F_SETLK)
6992
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
	     * new fcntl(SETLK) interface;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4167
	     * available on SYSV4 and Linux
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4168
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4169
	    struct flock flock;
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
	    flock.l_type = F_UNLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4172
	    flock.l_whence = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4173
	    flock.l_start = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4174
	    flock.l_len = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4175
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4176
		RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4177
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4178
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4179
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4180
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4181
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4182
# if defined(LOCK_EX) && defined(LOCK_UN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4183
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4184
	 * BSD 4.3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4185
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4186
	if (flock(fd, LOCK_UN) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4187
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4188
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4190
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4191
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4192
#  if defined(F_LOCK) && defined(F_UNLOCK)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4193
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4194
	 * SYSV3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4195
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4196
	if (lockf(fd, F_UNLOCK, 0) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4197
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4198
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4199
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4200
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4201
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4202
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4203
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4204
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4205
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4206
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4207
!UnixOperatingSystem class methodsFor:'file queries'!
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
caseSensitiveFilenames
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4210
    "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
  4211
     On MSDOS, this will return false;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4212
     on a real OS, we return true."
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
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4215
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4216
    "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
  4217
!
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
compressPath:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4220
    "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
  4221
     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
  4222
     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
  4223
     if realPath and popen failed."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4224
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4225
    |names n "{ Class: SmallInteger }" |
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4226
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4227
    names := pathName
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4228
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4229
    names := names asOrderedCollection.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4230
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4231
     cut off initial double-slashes
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4232
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4233
    [names startsWith:#('' '')] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4234
	names removeFirst.
3496
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4237
     cut off double-slashes at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4238
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4239
    [names endsWith:#('')] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4240
	names removeLast.
3496
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4243
     cut off current-dir at beginning
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4244
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4245
    n := names size.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4246
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4247
	names removeFirst.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4248
	n := n - 1.
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4251
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4252
     cut off parent-dirs at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4253
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4254
    [(n > 2)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4255
     and:[(names endsWith:#('..'))
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4256
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4257
	names removeLast; removeLast.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4258
	n := n - 2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4259
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4260
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4261
    ^ names asStringWith:self fileSeparator
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4262
		    from:1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4263
		    to:n
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4264
		    compressTabs:false final:nil
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4265
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4266
    "
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4267
     OperatingSystem compressPath:'./..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4268
     OperatingSystem compressPath:'/foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4269
     OperatingSystem compressPath:'foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4270
     OperatingSystem compressPath:'foo/bar/baz/../'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4271
     OperatingSystem compressPath:'foo/bar/baz/..///'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4272
     OperatingSystem compressPath:'///foo/bar/baz/..///'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4273
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4274
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4275
    "Modified: 1.11.1996 / 20:13:48 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4276
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4277
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4278
fileSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4279
    "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
  4280
     This character differs for MSDOS and other systems,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4281
     (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
  4282
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4283
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4284
    ^ $/
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4285
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4286
    "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
  4287
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4288
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4289
getDiskInfoOf:aDirectoryPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4290
    "return some disk info.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4291
     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
  4292
     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
  4293
     On unix, the information returned is (at least):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4294
	freeBytes
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4295
	totalBytes
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4296
    "
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4297
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4298
    |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
  4299
     fileSystemIdx sizeIdx usedIdx availIdx capacityIdx mountIdx|
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4300
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4301
    p := PipeStream readingFrom:('df -k ' , aDirectoryPath).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4302
    p isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4303
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4304
    [
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4305
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4306
    ] ensure:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4307
	p close.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4308
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4309
"/ Transcript showCR:outputText asString.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4310
    outputText isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4311
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4312
    outputText := outputText asCollectionOfLines.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4313
    outputText size < 2 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4314
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4315
    keys := (outputText at:1) asLowercase asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4316
    values := (outputText at:2) asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4317
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4318
    "/ 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
  4319
    "/ on some rude Unix versions ...
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4320
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4321
    fileSystemIdx := 1.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4322
    sizeIdx := 2.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4323
    usedIdx := 3.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4324
    availIdx := 4.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4325
    capacityIdx := 5.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4326
    mountIdx := 6.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4327
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4328
    values size < 6 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4329
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4330
    info := IdentityDictionary new.
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
    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
  4333
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4334
	info at:#percentUsed put:n
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4335
    ].
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
    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
  4338
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4339
	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
  4340
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4341
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4342
    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
  4343
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4344
	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
  4345
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4346
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4347
    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
  4348
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4349
	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
  4350
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4351
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4352
    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
  4353
    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
  4354
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4355
    ^ info
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4356
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
     OperatingSystem getDiskInfoOf:'/'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4359
     OperatingSystem getDiskInfoOf:'.'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4360
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4361
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4362
    "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
  4363
!
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4364
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4365
getDriveList
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4366
    "return a list of volumes in the system.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4367
     On unix, no such thing like a volume exists
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4368
     - 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
  4369
     On MSDOS, a list of drive letters is returned.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4370
     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
  4371
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4372
    "/
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4373
    "/ default: return array filled with
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4374
    "/ root, home and current directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4375
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4376
    ^ Array
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4377
	with:'/'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4378
	with:(self getHomeDirectory)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4379
	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
  4380
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4381
    "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
  4382
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4383
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4384
getMountedVolumes
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4385
    "return info about mounted volumes.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4386
     The amount of information returned depends upon the OS, and is
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4387
     not guaranteed to be consistent across architectures.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4388
     On unix, the information returned is (at least):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4389
	mountPoint - mount point
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4390
	fileSystem - device or NFS-remotePath
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4391
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4392
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4393
    |p outputText keys values info infoEntry|
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4394
4933
bfa38904104e use df -k
Claus Gittinger <cg@exept.de>
parents: 4923
diff changeset
  4395
    p := PipeStream readingFrom:('df -k').
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4396
    p isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4397
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4398
    [
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4399
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4400
    ] ensure:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4401
	p close.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4402
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4403
"/ Transcript showCR:outputText asString.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4404
    outputText isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4405
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4406
    outputText := outputText asCollectionOfLines.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4407
    outputText size < 2 ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4408
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4409
    keys := (outputText at:1) asLowercase asCollectionOfWords.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4410
    "/ we may have to validate the following column indices
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4411
    "/ on some rude Unix versions ...
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4412
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4413
    info := OrderedCollection new.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4414
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4415
    outputText from:2 do:[:line |
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4416
	values := line asCollectionOfWords.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4417
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4418
	values size >= 2 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4419
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4420
	    infoEntry := IdentityDictionary new.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4421
	    infoEntry at:#mountPoint put:(values last).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4422
	    infoEntry at:#fileSystem put:(values first).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4423
	    info add:infoEntry.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4424
	]
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4425
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4426
    ^ info
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4427
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4428
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4429
     OperatingSystem getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4430
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4431
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4432
    "Modified: / 22.5.1999 / 00:32:13 / cg"
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4433
!
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4434
4201
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4435
getNullDevice
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4436
    "return the name of the OS's null device"
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4437
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4438
    ^ '/dev/null'
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4439
!
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4440
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4441
infoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4442
    "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
  4443
     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
  4444
     the returned object) is:
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4445
	 type            - a symbol giving the files type
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4446
	 mode            - numeric access mode
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4447
	 uid             - owners user id
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4448
	 gid             - owners group id
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4449
	 size            - files size
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4450
	 id              - files number (i.e. inode number)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4451
	 accessed        - last access time (as Timestamp)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4452
	 modified        - last modification time (as Timestamp)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4453
	 statusChanged   - last status change time (as Timestamp)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4454
	 alternativeName     - (windows only:) the MSDOS name of the file
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4455
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4456
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4457
	 recordAttributes    - (VMS only:) recordAttributes
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4458
	 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
  4459
	 recordSize          - (VMS only:) record size.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4460
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4461
     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
  4462
     all of the information.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4463
     Return nil if such a file does not exist.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4464
     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
  4465
     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
  4466
     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
  4467
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4468
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4469
    |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
  4470
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4471
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4472
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4473
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4474
    if (!__isStringLike(aPathName)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4475
	error = @symbol(badArgument);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4476
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4477
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4478
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4479
# ifdef TRACE_STAT_CALLS
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4480
    printf("stat on '%s' for info\n", __stringVal(aPathName));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4481
# endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4482
    __BEGIN_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4483
    do {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4484
	ret = stat((char *) __stringVal(aPathName), &buf);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4485
    } while ((ret < 0) && (errno == EINTR));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4486
    __END_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4487
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4488
    if (ret < 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4489
	error = __MKSMALLINT(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4490
	@global(LastErrorNumber) = error;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4491
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4492
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4493
    switch (buf.st_mode & S_IFMT) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4494
	case S_IFDIR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4495
	    type = @symbol(directory);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4496
	    break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4497
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4498
	case S_IFREG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4499
	    type = @symbol(regular);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4500
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4501
# ifdef S_IFCHR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4502
	case S_IFCHR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4503
	    type = @symbol(characterSpecial);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4504
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4505
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4506
# ifdef S_IFBLK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4507
	case S_IFBLK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4508
	    type = @symbol(blockSpecial);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4509
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4510
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4511
# ifdef S_IFMPC
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4512
	case S_IFMPC:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4513
	    type = @symbol(multiplexedCharacterSpecial);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4514
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4515
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4516
# ifdef S_IFMPB
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4517
	case S_IFMPB:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4518
	    type = @symbol(multiplexedBlockSpecial);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4519
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4520
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4521
# ifdef S_IFLNK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4522
	case S_IFLNK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4523
	    type = @symbol(symbolicLink);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4524
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4525
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4526
# ifdef S_IFSOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4527
	case S_IFSOCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4528
	    type = @symbol(socket);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4529
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4530
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4531
# ifdef S_IFIFO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4532
	case S_IFIFO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4533
	    type = @symbol(fifo);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4534
	    break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4535
# endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4536
	default:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4537
	    type = @symbol(unknown);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4538
	    break;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4539
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4540
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4541
    if (sizeof(buf.st_ino) == 8) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4542
	id = __MKUINT64(&buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4543
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4544
	id = __MKUINT(buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4545
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4546
    mode = __MKSMALLINT(buf.st_mode & 0777);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4547
    uid = __MKSMALLINT(buf.st_uid);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4548
    gid = __MKSMALLINT(buf.st_gid);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4549
    nLink = __MKSMALLINT(buf.st_nlink);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4550
    if (sizeof(buf.st_size) == 8) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4551
	size = __MKINT64(&buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4552
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4553
	size = __MKINT(buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4554
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4555
    aOStime = __MKUINT(buf.st_atime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4556
    mOStime = __MKUINT(buf.st_mtime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4557
    cOStime = __MKUINT(buf.st_ctime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4558
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4559
    out:;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4560
%}.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4561
     mode notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4562
	"/ now done lazy in FileStatusInfo
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4563
	"/ atime := Timestamp fromOSTime:(aOStime * 1000).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4564
	"/ mtime := Timestamp fromOSTime:(mOStime * 1000).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4565
	"/ ctime := Timestamp fromOSTime:(cOStime * 1000).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4566
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4567
	^ FileStatusInfo
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4568
		    type:type
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4569
		    mode:mode
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4570
		    uid:uid
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4571
		    gid:gid
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4572
		    size:size
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4573
		    id:id
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4574
		    accessed:aOStime
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4575
		    modified:mOStime
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4576
		    statusChanged:cOStime
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4577
		    path:nil
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4578
		    numLinks:nLink.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4579
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4580
    error notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4581
	^ nil.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4582
    ].
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4583
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4584
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4585
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4586
   "
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4587
    OperatingSystem infoOf:'/ccccccc'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4588
    (OperatingSystem infoOf:'/') uid
7889
5e96f8cdf9aa Fix comment
Stefan Vogel <sv@exept.de>
parents: 7886
diff changeset
  4589
    (OperatingSystem infoOf:'/') accessTime
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4590
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4591
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4592
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4593
isDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4594
    "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
  4595
     (i.e. exists and is a directory).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4596
     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
  4597
     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
  4598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4599
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4600
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4601
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4602
    if (__isString(aPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4603
	struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4605
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4606
	printf("stat on '%s' for isDirectory\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4607
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4608
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4609
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4610
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4611
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4612
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4613
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4614
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4615
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4616
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4617
	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
  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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4621
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4622
    "an alternative implementation would be:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4623
	^ (self infoOf:aPathName) type == #directory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4624
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4625
!
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
isExecutable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4628
    "return true, if the given file is executable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4629
     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
  4630
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4631
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4632
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4633
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4634
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4635
# ifdef TRACE_ACCESS_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4636
	printf("access on '%s' for executable\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4637
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4638
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4639
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4640
	    ret = access(__stringVal(aPathName), X_OK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4641
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4642
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4643
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4644
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4645
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4646
	RETURN ( ((ret == 0) ? true : false) );
3496
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4649
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4650
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4651
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4652
isReadable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4653
    "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
  4654
     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
  4655
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4656
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4657
    int ret;
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
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4660
# ifdef TRACE_ACCESS_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4661
	printf("access on '%s' for readable\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4662
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4663
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4664
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4665
	    ret = access(__stringVal(aPathName), R_OK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4666
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4667
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4668
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4669
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4670
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4671
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4672
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4673
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4674
    ^ self primitiveFailed
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
isValidPath:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4678
    "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
  4679
     (i.e. the file or directory exists)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4680
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4681
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4682
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4683
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4684
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4685
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4686
# ifdef TRACE_STAT_CALLS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4687
	printf("stat on '%s' for isValidPath\n", __stringVal(aPathName));
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4688
# endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4689
	__BEGIN_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4690
	do {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4691
	    ret = stat((char *) __stringVal(aPathName), &buf);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4692
	} while ((ret < 0) && (errno == EINTR));
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4693
	__END_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4694
	if (ret < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4695
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4696
	    RETURN (false);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4697
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4698
	RETURN ( ret ? false : true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4699
    }
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
    ^ self primitiveFailed
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4702
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4703
"/ alternative:
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4704
"/        ^ (self infoOf:aPathName) notNil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4705
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4706
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4707
isWritable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4708
    "return true, if the given file is writable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4709
     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
  4710
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4711
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4712
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4713
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4714
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4715
# ifdef TRACE_ACCESS_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4716
	printf("access on '%s' for writable\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4717
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4718
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4719
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4720
	    ret = access(__stringVal(aPathName), W_OK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4721
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4722
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4723
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4724
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4725
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4726
	RETURN ( ((ret == 0) ? true : false) );
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4730
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4731
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4732
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
  4733
    "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
  4734
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4735
     The info (for which corresponding access methods are understood by
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4736
     the returned object) is:
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4737
         type            - a symbol giving the files type
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4738
         mode            - numeric access mode
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4739
         uid             - owners user id
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4740
         gid             - owners group id
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4741
         size            - files size
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4742
         id              - files number (i.e. inode number)
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4743
         accessed        - last access time (as Timestamp)
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4744
         modified        - last modification time (as Timestamp)
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4745
         statusChanged   - last status change time (as Timestamp)
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4746
         alternativeName     - (windows only:) the MSDOS name of the file
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4747
         recordFormatNumeric - (VMS only:) numeric value of the recordFormat
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4748
         recordFormat        - (VMS only:) symbolic value of the recordFormat
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4749
         recordAttributes    - (VMS only:) recordAttributes
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4750
         fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4751
         recordSize          - (VMS only:) record size.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4752
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4753
     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
  4754
     all of the information.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4755
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4756
     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
  4757
     (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
  4758
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4759
     Return the info about the link itself,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4760
     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
  4761
     in case of a symbolic link."
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4762
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4763
    |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
  4764
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4765
%{  /* STACK: 1200 */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  4766
#if defined(S_IFLNK)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4767
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4768
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4769
    char pathBuffer[1024];
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4770
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4771
    if (__isStringLike(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
  4772
        __BEGIN_INTERRUPTABLE__
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4773
        do {
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4774
            ret = lstat((char *) __stringVal(aPathName), &buf);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4775
        } while ((ret < 0) && (errno == EINTR));
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4776
        __END_INTERRUPTABLE__
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4777
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4778
        if (ret < 0) {
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4779
            @global(LastErrorNumber) = __MKSMALLINT(errno);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4780
            RETURN ( nil );
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4781
        }
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4782
        switch (buf.st_mode & S_IFMT) {
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4783
    # ifdef S_IFLNK
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4784
            case S_IFLNK:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4785
                type = @symbol(symbolicLink);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4786
                if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4787
                    @global(LastErrorNumber) = __MKSMALLINT(errno);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4788
                    RETURN ( nil );
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4789
                }
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4790
                pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4791
                path = __MKSTRING(pathBuffer);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4792
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4793
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4794
            case S_IFDIR:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4795
                type = @symbol(directory);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4796
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4797
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4798
            case S_IFREG:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4799
                type = @symbol(regular);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4800
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4801
    # ifdef S_IFCHR
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4802
            case S_IFCHR:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4803
                type = @symbol(characterSpecial);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4804
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4805
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4806
    # ifdef S_IFBLK
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4807
            case S_IFBLK:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4808
                type = @symbol(blockSpecial);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4809
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4810
    # endif
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_IFMPC
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4812
            case S_IFMPC:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4813
                type = @symbol(multiplexedCharacterSpecial);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4814
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4815
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4816
    # ifdef S_IFMPB
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4817
            case S_IFMPB:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4818
                type = @symbol(multiplexedBlockSpecial);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4819
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4820
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4821
    # ifdef S_IFSOCK
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4822
            case S_IFSOCK:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4823
                type = @symbol(socket);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4824
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4825
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4826
    # ifdef S_IFIFO
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4827
            case S_IFIFO:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4828
                type = @symbol(fifo);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4829
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4830
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4831
            default:
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4832
                type = @symbol(unknown);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4833
                break;
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4834
        }
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4835
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4836
        if (sizeof(buf.st_ino) == 8) {
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4837
            id = __MKUINT64(&buf.st_ino);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4838
        } else {
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4839
            id = __MKUINT(buf.st_ino);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4840
        }
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4841
        mode = __MKSMALLINT(buf.st_mode & 0777);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4842
        uid = __MKSMALLINT(buf.st_uid);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4843
        gid = __MKSMALLINT(buf.st_gid);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4844
        nLink = __MKSMALLINT(buf.st_nlink);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4845
        if (sizeof(buf.st_size) == 8) {
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4846
            size = __MKINT64(&buf.st_size);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4847
        } else {
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4848
            size = __MKINT(buf.st_size);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4849
        }
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4850
        aOStime = __MKUINT(buf.st_atime);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4851
        mOStime = __MKUINT(buf.st_mtime);
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4852
        cOStime = __MKUINT(buf.st_ctime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4853
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4854
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4855
    RETURN ( nil );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4856
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4857
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4858
    mode notNil ifTrue:[
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4859
        ^ FileStatusInfo
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4860
            type:type
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4861
            mode:mode
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4862
            uid:uid
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4863
            gid:gid
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4864
            size:size
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4865
            id:id
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4866
            accessed:aOStime
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4867
            modified:mOStime
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4868
            statusChanged:cOStime
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4869
            path:path
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4870
            numLinks:nLink.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4871
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4872
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4873
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4874
   "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4875
    OperatingSystem infoOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4876
    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
  4877
    OperatingSystem linkInfoOf:'/usr/tmp'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4878
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4879
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4880
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4881
mountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4882
    "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
  4883
     As this might be expensive on some systems,
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4884
     the info is cached for some time (5 minutes)"
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4885
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4886
    CacheMountPointsTimeStamp notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4887
	Timestamp now > (CacheMountPointsTimeStamp addSeconds:5*60) ifTrue:[
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4888
	    CacheMountPointsTimeStamp := CachedMountPoints := nil.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4889
	].
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4890
    ].
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4891
    CachedMountPoints notNil ifTrue:[ ^ CachedMountPoints ].
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4892
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4893
    '/proc/mounts' asFilename exists ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4894
	CachedMountPoints := self mountPointsFromProcFS.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4895
	CacheMountPointsTimeStamp := Timestamp now.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4896
	^ CachedMountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4897
    ].
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4898
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4899
    "/ 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
  4900
    ^ #()
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4901
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4902
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4903
     OperatingSystem mountPoints
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4904
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4905
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4906
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4907
parentDirectoryName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4908
    "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
  4909
     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
  4910
     for other systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4911
     (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
  4912
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4913
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4914
    ^ '..'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4915
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4916
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4917
pathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4918
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4919
     - thats the full pathname of the directory, starting at '/'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4920
     This method needs the path to be valid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4921
     (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
  4922
     Notice: if symbolic links are involved, the result may look different
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4923
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4924
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4925
    |p path command|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4926
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4927
    "some systems have a convenient function for this ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4928
    path := self primPathNameOf:pathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4929
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4930
    path isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4931
	(self isValidPath:pathName) ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4932
	    p := pathName.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4933
	    [(p size > 1)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4934
	     and:[p endsWith:(self fileSeparator)]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4935
	    ] whileTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4936
		p := p copyWithoutLast:1.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4937
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4938
	    ^ p
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4939
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4940
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4941
	(SlowFork==true or:[PipeFailed==true]) ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4942
	    PipeStream openErrorSignal handle:[:ex |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4943
		PipeFailed := true.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4944
		'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4945
		ex return.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4946
	    ] do:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4947
		"have to fall back ..."
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4948
		command := 'cd "' , pathName , '"; pwd'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4949
		p := PipeStream readingFrom:command.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4950
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4951
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4952
	    (p isNil or:[p atEnd]) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4953
		('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4954
	    ] ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4955
		path := p nextLine.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4956
		p close.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4957
	    ]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4958
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4959
	path isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4960
	    "/
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4961
	    "/ return the original - there is nothing else can we do
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4962
	    "/
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4963
	    path := pathName
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
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4966
	    path := self compressPath:path
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4967
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4968
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4969
    ^ path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4970
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4971
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4972
     OperatingSystem pathNameOf:'.'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4973
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4974
     OperatingSystem pathNameOf:'../../..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4975
     OperatingSystem pathNameOf:'..'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4976
     OperatingSystem pathNameOf:'/tmp////'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4977
     OperatingSystem pathNameOf:'/foo/bar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4978
     OperatingSystem pathNameOf:'/foo/bar/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4979
     OperatingSystem pathNameOf:'/foo/bar//'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4980
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4981
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4982
    "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
  4983
    "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
  4984
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4985
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4986
primIdOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4987
    "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
  4988
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  4989
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4990
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4991
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4992
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4993
    OBJ retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4994
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4995
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4996
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4997
	printf("stat on '%s' for id\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4998
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4999
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5000
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5001
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5002
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5003
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5004
	if (ret >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5005
	    ino = buf.st_ino;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5006
	    retVal = __MKUINT(ino);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5007
	    RETURN (retVal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5008
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5009
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5010
	RETURN (nil);
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
    RETURN (nil);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5013
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5014
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5015
5492
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5016
primInfoOf:aPathName
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5017
   "for rel5 only"
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5018
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5019
   ^ self primitiveFailed
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5020
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5021
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5022
!
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5023
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5024
primPathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5025
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5026
     - 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
  5027
     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
  5028
     realPath library function.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5029
     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
  5030
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5031
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5032
    |path|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5033
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5034
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5035
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5036
    if (__isString(pathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5037
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5038
#ifdef HAS_GETCWD
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5039
	if (strcmp(__stringVal(pathName), ".") == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5040
	    char nameBuffer[MAXPATHLEN + 1];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5041
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5042
	    if (@global(CurrentDirectory) == nil) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5043
		if (getcwd(nameBuffer, MAXPATHLEN)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5044
		    OBJ d;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5045
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5046
		    @global(CurrentDirectory) = d = __MKSTRING(nameBuffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5047
		    __GSTORE(d);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5048
		}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5049
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5050
	    RETURN (@global(CurrentDirectory));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5051
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5052
#endif /* HAS_GETCWD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5053
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5054
#ifdef HAS_REALPATH
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5055
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5056
	    char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5057
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5058
	    if (realpath(__stringVal(pathName), nameBuffer)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5059
		RETURN ( __MKSTRING(nameBuffer) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5060
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5061
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5062
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5063
#endif /* ! HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5064
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5065
%}.
5451
2e21cd54b656 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5448
diff changeset
  5066
    ^ nil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5067
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5068
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5069
timeOfLastAccess:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5070
    "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
  5071
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5072
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5073
    "could be implemented as:
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5074
	(self infoOf:aPathName) accessed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5075
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5076
    |osSeconds i|
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
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5079
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5080
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5081
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5082
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5083
# ifdef TRACE_STAT_CALLS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5084
	printf("stat on '%s' for timeOfLastAccess\n", __stringVal(aPathName));
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5085
# endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5086
	__BEGIN_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5087
	do {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5088
	    ret = stat((char *) __stringVal(aPathName), &buf);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5089
	} while (ret < 0 && errno == EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5090
	__END_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5091
	if (ret < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5092
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5093
	    RETURN (nil);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5094
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5095
	osSeconds = __MKUINT(buf.st_atime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5096
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5097
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5098
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
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
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5101
    i notNil ifTrue:[^ i accessed].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5102
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5103
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5104
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5105
     OperatingSystem timeOfLastAccess:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5106
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5107
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5108
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5109
timeOfLastChange:aPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5110
    "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
  5111
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5112
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5113
    "could be implemented as:
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5114
	(self infoOf:aPathName) modified
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5115
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5116
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5117
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5118
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5119
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5120
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5121
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5122
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5123
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5124
# ifdef TRACE_STAT_CALLS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5125
	printf("stat on '%s' for timeOfLastChange\n", __stringVal(aPathName));
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5126
# endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5127
	__BEGIN_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5128
	do {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5129
	    ret = stat((char *) __stringVal(aPathName), &buf);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5130
	} while (ret < 0 && errno == EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5131
	__END_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5132
	if (ret < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5133
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5134
	    RETURN ( nil );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5135
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5136
	osSeconds = __MKUINT(buf.st_mtime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5137
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5138
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5139
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
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
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5142
    i notNil ifTrue:[^ i modified].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5143
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5144
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5145
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5146
     OperatingSystem timeOfLastChange:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5147
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5148
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5150
typeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5151
    "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
  5152
     nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5153
     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
  5154
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5155
    |i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5157
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5158
     this could have been implemented as:
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5159
	(self infoOf:aPathName) type
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5160
     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
  5161
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5162
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5163
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5164
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5165
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5166
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5167
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5168
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5169
	printf("stat on '%s' for type\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5170
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5171
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5172
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5173
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5174
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5175
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5176
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5177
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5178
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5179
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5180
	switch (buf.st_mode & S_IFMT) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5181
	    case S_IFDIR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5182
		RETURN ( @symbol(directory) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5183
	    case S_IFREG:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5184
		RETURN ( @symbol(regular) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5185
# ifdef S_IFCHR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5186
	    case S_IFCHR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5187
		RETURN ( @symbol(characterSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5188
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5189
# ifdef S_IFBLK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5190
	    case S_IFBLK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5191
		RETURN ( @symbol(blockSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5192
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5193
# ifdef S_IFLNK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5194
	    case S_IFLNK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5195
		RETURN ( @symbol(symbolicLink) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5196
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5197
# ifdef S_IFSOCK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5198
	    case S_IFSOCK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5199
		RETURN ( @symbol(socket) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5200
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5201
# ifdef S_IFIFO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5202
	    case S_IFIFO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5203
		RETURN ( @symbol(fifo) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5204
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5205
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5206
		RETURN ( @symbol(unknown) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5207
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5208
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5209
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5210
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5211
    i notNil ifTrue:[^ i type].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5212
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5214
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5215
     OperatingSystem typeOf:'/'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5216
     OperatingSystem typeOf:'.'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5217
     OperatingSystem typeOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5218
     OperatingSystem typeOf:'resources/motif.style'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5219
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5220
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5221
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5222
volumeNameOf:aPathString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5223
    "return the volumeName of the argument, aPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5224
     - thats the name of the volume where aPath is.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5225
     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
  5226
     this always returns an empty string."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5227
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5228
    ^ ''
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5229
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5230
    "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
  5231
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5232
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5233
!UnixOperatingSystem class methodsFor:'interrupts & signals'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5234
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5235
defaultSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5236
    "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
  5237
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5238
     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
  5239
     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
  5240
     default for SIGQUIT (^ \) is to dump core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5241
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5242
     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
  5243
     a signal."
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5246
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5247
    if (__isSmallInteger(signalNumber)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5248
#ifdef SIG_DFL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5249
	signal(__intVal(signalNumber), SIG_DFL);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5250
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5251
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5252
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5253
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5254
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5255
     this error is triggered on non-integer argument
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
    ^ self primitiveFailed
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
    "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
  5260
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5261
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5262
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5263
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5264
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5265
     'normal ^C handling again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5266
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5267
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5268
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5269
disableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5270
    "turn off IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5271
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5272
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5273
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5274
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5275
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5276
#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
  5277
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5278
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5279
# if defined(SYSV4)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5280
	ret = ioctl(f, I_SETSIG, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5281
# else /*! SYSV4*/
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5282
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5283
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5284
	 * if already clear, there is no need for this syscall ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5285
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5286
	if (flags & FASYNC) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5287
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5288
	    if (ret >= 0) ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5289
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5290
	    ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5291
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5292
# endif /* !SYSV4 */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5293
	RETURN ( __MKSMALLINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5294
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5295
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5296
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5297
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5298
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5299
     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
  5300
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5301
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5302
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5303
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5304
disableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5305
    "disable (Unix-) signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5306
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5307
     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
  5308
     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
  5309
     handling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5310
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5311
     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
  5312
     a signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5313
     Use only for fully debugged stand alone applications."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5314
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5315
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5316
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5317
    if (__isSmallInteger(signalNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5318
	int sigNo = __intVal(signalNumber);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5319
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5320
	if (sigNo == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5321
	    RETURN (self);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5322
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5323
#ifdef SIG_IGN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5324
	signal(sigNo, SIG_IGN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5325
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5326
#endif
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5329
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5330
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5331
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5332
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5333
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5334
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5335
     'now, ^C is totally ignored ...' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5336
     OperatingSystem disableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5337
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5338
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5339
     '^C handled again.' printNewline
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5342
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5343
disableTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5344
    "disable timer interrupts.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5345
     WARNING:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5346
	the system will not operate correctly with timer interrupts
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5347
	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
  5348
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5349
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5350
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5351
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5352
    struct itimerval dt;
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
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5355
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5356
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5357
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5358
    setitimer(ITIMER_REAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5359
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5360
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5361
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5362
# if defined(USE_SLOW_ALARM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5363
#  if defined(SIGALRM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5364
    alarm(0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5365
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5366
#  endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5367
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5368
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5369
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5370
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5371
    ^ false
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5374
enableChildSignalInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5375
    "enable childSignal interrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5376
     (SIGCHLD, if the architecture supports it).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5377
     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
  5378
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5379
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5380
    self enableSignal:(self sigCHLD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5381
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5382
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5383
enableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5384
    "turn on IO interrupts for a filedescriptor"
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5387
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5388
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5389
#ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5390
    extern void __signalIoInterrupt();
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
    static int firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5393
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5394
#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
  5395
    /*
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5396
     * 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
  5397
     * (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
  5398
     */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5399
# ifdef SIGIO
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5400
#  define THESIGNAL SIGIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5401
# else
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5402
#  ifdef SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5403
#   define THESIGNAL SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5404
#  else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5405
#   ifdef SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5406
#    define THESIGNAL SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5407
#   endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5408
#  endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5409
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5410
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5411
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5412
	if (firstCall) {
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5413
# ifdef HAS_SIGACTION
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5414
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5415
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5416
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5417
	     * Do not add SA_RESTART here. A signal can cause a
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5418
	     * thread switch, another thread can do a garbage collect
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5419
	     * and restarted system calls may write into old
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5420
	     * (collected) addresses.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5421
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5422
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5423
	    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
  5424
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5425
	    act.sa_handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5426
	    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
  5427
# else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5428
#  ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5429
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5430
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5431
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5432
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5433
	    vec.sv_handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5434
	    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
  5435
#  else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5436
	    signal(THESIGNAL, __signalIoInterrupt);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5437
#  endif /* SIGVEC */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5438
# endif /* SIGACTION */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5439
	    firstCall = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5440
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5441
#undef THESIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5442
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5443
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5444
# if defined(SYSV4)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5445
	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
  5446
# else /*! SYSV4*/
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5447
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5448
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5449
	 * if already set, there is no need for this syscall ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5450
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5451
	if (flags & FASYNC) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5452
	    ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5453
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5454
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5455
	    if (ret >= 0) ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5456
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5457
# endif /*!SYSV4*/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5458
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5459
# if defined(F_SETOWN) || defined(FIOSETOWN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5460
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5461
	    int pid;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5462
	    int ok;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5463
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5464
	    pid = getpid();
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5465
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5466
#  if defined(F_SETOWN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5467
	    ok = fcntl(f, F_SETOWN, pid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5468
	    /* 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
  5469
#  else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5470
	    ok = ioctl(f, FIOSETOWN, &pid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5471
	    /* 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
  5472
#  endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5473
	    if (ok < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5474
		ret = ok;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5475
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5476
	}
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5477
# endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5478
	RETURN ( __MKUINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5479
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5480
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5481
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5482
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5483
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5484
     or if the system does not support SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5485
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5486
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5487
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5488
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5489
enableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5490
    "enable (Unix-)signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5491
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5492
     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
  5493
     (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
  5494
     sends #signalInterrupt:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5495
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5496
     NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5497
     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
  5498
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5499
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5500
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5501
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5502
#ifdef NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5503
# define SIG_LIMIT NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5504
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5505
# ifdef SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5506
#  define SIG_LIMIT SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5507
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5508
#  ifdef SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5509
#   define SIG_LIMIT SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5510
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5511
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5512
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5513
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5514
#if defined(SIGPOLL) && !defined(SIGIO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5515
# define SIGIO SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5516
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5517
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5518
#ifdef SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5519
# define CHILD_SIGNAL   SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5520
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5521
# ifdef SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5522
#  define CHILD_SIGNAL  SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5523
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5524
#endif
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
    int sigNr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5527
#if defined(SIGINT) || defined(SIGQUIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5528
# ifndef __signalUserInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5529
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5530
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5531
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5532
#ifdef SIGFPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5533
# ifndef __signalFpExceptionInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5534
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
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
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5538
# ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5539
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5542
#ifdef CHILD_SIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5543
# ifndef __signalChildInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5544
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5545
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5546
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5547
#ifdef SIGPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5548
# ifndef __signalPIPEInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5549
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5550
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5551
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5552
#ifdef SIGBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5553
# ifndef __signalBUSInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5554
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5557
#ifdef SIGSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5558
# ifndef __signalSEGVInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5559
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5562
#if defined(SIGILL) || defined(SIGEMT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5563
# ifndef __signalTrapInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5564
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5567
#ifdef SIGALRM
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
  5568
# ifndef __signalTimerInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5569
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5572
#ifndef __signalInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5573
    extern void __signalInterrupt(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
    void (*handler)(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5576
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5577
    if (__isSmallInteger(signalNumber)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5578
     && ((sigNr = __intVal(signalNumber)) >= 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5579
#ifdef SIG_LIMIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5580
     &&  (sigNr <= SIG_LIMIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5581
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5582
    ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5583
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5584
	 * standard signals are forced into standard handlers
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5585
	 * - all others go into general signalInterrupt
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5586
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5587
#if defined(SIGPOLL) && defined(SIGIO)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5588
	if (sigNr == SIGPOLL)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5589
	    sigNr = SIGIO;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5590
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5591
	switch (sigNr) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5592
	    case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5593
		/* enabling a non-supported signal */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5594
		RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5595
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5596
#ifdef SIGBREAK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5597
	    case SIGBREAK:
3496
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
#ifdef SIGINT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5600
	    case SIGINT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5601
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5602
#ifdef SIGQUIT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5603
	    case SIGQUIT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5604
#endif
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5605
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5606
		handler = __signalUserInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5607
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5608
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5609
#ifdef SIGFPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5610
	    case SIGFPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5611
		handler = __signalFpExceptionInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5612
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5613
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5614
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5615
#ifdef SIGPIPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5616
	    case SIGPIPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5617
		handler = __signalPIPEInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5618
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5619
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5620
#ifdef SIGBUS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5621
	    case SIGBUS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5622
		handler = __signalBUSInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5623
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5624
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5625
#ifdef SIGSEGV
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5626
	    case SIGSEGV:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5627
		handler = __signalSEGVInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5628
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5629
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5630
#ifdef SIGILL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5631
	    case SIGILL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5632
		handler = __signalTrapInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5633
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5634
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5635
#ifdef SIGEMT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5636
	    case SIGEMT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5637
		handler = __signalTrapInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5638
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5639
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5640
#ifdef SIGIO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5641
	    case SIGIO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5642
		handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5643
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5644
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5645
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5646
#ifdef CHILD_SIGNAL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5647
	    case CHILD_SIGNAL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5648
		handler = __signalChildInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5649
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5650
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5651
#ifdef SIGALRM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5652
	    case SIGALRM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5653
		handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5654
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5655
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5656
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5657
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5658
		handler = __signalInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5659
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5660
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5661
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5662
	{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5663
#ifdef HAS_SIGACTION
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5664
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5665
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5666
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5667
	     * Do not add SA_RESTART here. A signal can cause a
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5668
	     * thread switch, another thread can do a garbage collect
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5669
	     * and restarted system calls may write into old
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5670
	     * (collected) addresses.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5671
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5672
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5673
	    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
  5674
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5675
	    act.sa_handler = handler;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5676
	    sigaction(sigNr, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5677
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5678
# ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5679
	    struct sigvec vec;
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
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5682
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5683
	    vec.sv_handler = handler;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5684
	    sigvec(sigNr, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5685
# else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5686
	    (void) signal(sigNr, handler);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5687
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5688
#endif
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
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5692
	 * maybe, we should ret the old enable-status
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5693
	 * as boolean here ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5694
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5695
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5696
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5697
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5698
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5699
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5700
     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
  5701
     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
  5702
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5703
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5704
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5705
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5706
enableTimer:milliSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5707
    "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
  5708
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5709
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5710
    int millis;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5711
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5712
    millis = __intVal(milliSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5713
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5714
#ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5715
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5716
	static int firstCall = 1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5717
# ifndef __signalTimerInterrupt
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5718
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5719
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5720
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5721
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5722
# ifdef HAS_SIGACTION
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5723
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5724
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5725
	    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
  5726
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5727
	    act.sa_handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5728
	    sigaction(SIGALRM, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5729
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5730
#  ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5731
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5732
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5733
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5734
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5735
	    vec.sv_handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5736
	    sigvec(SIGALRM, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5737
#  else /* neither SIGACTION nor SIGVEC */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5738
	    signal(SIGALRM, __signalTimerInterrupt);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5739
#  endif /* stupid system  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5740
# endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5741
	    firstCall = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5742
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5743
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5744
#endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5745
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5746
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5747
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5748
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5749
	struct itimerval dt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5750
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5751
	dt.it_interval.tv_sec = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5752
	dt.it_interval.tv_usec = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5753
	dt.it_value.tv_sec = millis / 1000;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5754
	dt.it_value.tv_usec = (millis % 1000) * 1000;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5755
	setitimer(ITIMER_REAL, &dt, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5756
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5757
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5758
#else /* no ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5759
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5760
# ifdef USE_SLOW_ALARM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5761
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5762
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5763
	 * last fallback - use alarm (which only gives 1 second resolution).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5764
	 * 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
  5765
	 * with this. The consequence is that pressing CTRL-C processing and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5766
	 * thread switching will take place much delayed.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5767
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5768
	alarm(1);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5769
	RETURN(true);
3496
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
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5772
#endif /* ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5773
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5774
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5775
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5776
6536
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5777
isFatalSignal:aNumber
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5778
   "return true if a signal with number aNumber is a fatal signal,
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5779
    i.e. some severe internal error occured"
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5780
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5781
   ^ (aNumber == self sigSEGV)
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5782
     or:[aNumber == self sigILL
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5783
     or:[aNumber == self sigBUS]]
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5784
!
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5785
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5786
killProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5787
    "kill a unix process.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5788
     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
  5789
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5790
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5791
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5792
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5793
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5794
    self sendSignal:(self sigKILL) to:processId.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5795
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5796
    "Modified: / 10.6.1998 / 11:59:12 / cg"
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5797
!
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5798
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5799
killProcessGroup:processGroupId
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5800
    "kill a unix process group.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5801
     The process has a no chance to do some cleanup.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5802
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5803
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5804
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5805
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5806
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5807
    self sendSignal:(self sigKILL) to:(processGroupId negated).
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5808
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5809
    "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
  5810
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5811
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5812
sendSignal:signalNumber to:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5813
    "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
  5814
     Returns false if any error occurred, true otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5815
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5816
     Do not confuse UNIX signals with Smalltalk-Signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5817
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5818
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5819
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5820
	      OperatingSystem>>getStatusOfProcess:aProcessId
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5821
	      if the signal terminates that process."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5822
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5823
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5824
    if (__bothSmallInteger(signalNumber, processId)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5825
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5826
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5827
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5828
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5829
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5830
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5831
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5832
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5833
    "/ either invalid argument (non-integers)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5834
    "/ or not supported by OS
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5837
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5838
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5839
startSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5840
    "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
  5841
     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
  5842
     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
  5843
     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
  5844
     (which is of course less correct).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5845
     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
  5846
	       spy interrupts."
3496
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5849
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5850
#ifndef __spyInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5851
    extern void __spyInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5852
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5853
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5854
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5855
    struct itimerval dt;
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
# ifdef SIGVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5858
    signal(SIGVTALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5859
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5860
#  ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5861
    signal(SIGALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5862
#  else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5863
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5864
     * mhmh - system has neither SIGBTALRM nor SIGALRM ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5865
     * what should we do here ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5866
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5867
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5868
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5869
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5870
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5871
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5872
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5873
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5874
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5875
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5876
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5877
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5878
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5879
    ^ false
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5882
stopSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5883
    "stop spy timing - disable spy timer.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5884
     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
  5885
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5886
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5887
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5888
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5889
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5890
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5891
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5892
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5893
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5894
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5895
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5896
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5897
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5898
#endif /* ITIMER_VIRTUAL */
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
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5901
!
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
terminateProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5904
    "terminate a unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5905
     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
  5906
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5907
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5908
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5909
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5910
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5911
    self sendSignal:(self sigTERM) to:processId.
3496
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
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5914
    "Modified: / 27.1.1998 / 20:05:47 / cg"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5917
terminateProcessGroup:processGroupId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5918
    "terminate a unix process group.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5919
     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
  5920
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5921
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5922
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5923
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5924
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5925
    self sendSignal:(self sigTERM) to:(processGroupId negated).
3496
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
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5928
    "Created: / 23.4.1996 / 16:40:34 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5929
    "Modified: / 27.1.1998 / 20:05:59 / cg"
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
7292
db594b46a780 category changes
Claus Gittinger <cg@exept.de>
parents: 7289
diff changeset
  5932
!UnixOperatingSystem class methodsFor:'ipc support-UNIX'!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5933
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5934
makePTYPair
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5935
    "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
  5936
     nil on failure.
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5937
     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
  5938
     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
  5939
     public interface."
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5940
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5941
    |fdS fdM|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5942
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5943
%{
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5944
    /*
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5945
     * Find a pseudo tty to use and open both sides.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5946
     *  _fdM receives the master file descriptor while _fdS
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5947
     *  receives the slave.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5948
     */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5949
3536
adad0d12c9a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3534
diff changeset
  5950
#ifdef IRIX5
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5951
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5952
    char *slaveName;
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5953
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5954
    slaveName = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5955
    if ((slaveName != 0) && (_fdM >= 0)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5956
	_fdS = open(slaveName, O_RDWR);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5957
	if (_fdS < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5958
	    (void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5959
	    _fdS = _fdM = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5960
	}
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5961
    } else {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5962
	_fdM -1;
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5963
    }
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5964
    if ((_fdM >= 0) && (_fdS >= 0)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5965
	 fdM = __MKSMALLINT(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5966
	 fdS = __MKSMALLINT(_fdS);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5967
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5968
#   define PTY_IS_IMPLEMENTED 1
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5969
#endif /* IRIX5 */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5970
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5971
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5972
#if defined(HAS_UNIX98_PTY)
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5973
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5974
    char *slaveName;
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5975
    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
  5976
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5977
    _fdM = open("/dev/ptmx", O_RDWR | O_NOCTTY);
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5978
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5979
    if (_fdM >= 0) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5980
	/*
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5981
	** grantpt() changes owner, group and mode of the pseudo-tty
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5982
	*/
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5983
	grantpt(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5984
	unlockpt(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5985
	slaveName = ptsname(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5986
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5987
	if (slaveName != NULL) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5988
	    /* printf("slave is: %s\n", slaveName); */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5989
	    _fdS = open(slaveName, O_RDWR);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5990
	    if (_fdS < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5991
		(void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5992
		_fdS = _fdM = -1;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5993
	    }
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5994
#if defined(UNIXWARE) || defined(solaris)
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5995
	    else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5996
		/* push terminal modules on stream */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5997
		ioctl(_fdS, I_PUSH, "ptem");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5998
		ioctl(_fdS, I_PUSH, "ldterm");
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5999
	    }
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6000
#endif
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6001
	} else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6002
	    (void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6003
	    _fdS = _fdM = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6004
	}
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6005
    }
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6006
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6007
    if ((_fdM >= 0) && (_fdS >= 0)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6008
	 fdM = __MKSMALLINT(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6009
	 fdS = __MKSMALLINT(_fdS);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6010
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6011
#   define PTY_IS_IMPLEMENTED 1
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6012
#endif /* HAS_UNIX98_PTY */
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6013
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6014
#if !defined(PTY_IS_IMPLEMENTED)
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6015
# ifdef LINUX
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6016
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6017
#   define PT_INDEX      5
3550
6c3824d07eac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  6018
#   define PTY_1_CHARS  "pqrstuabcdevwxyz"
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6019
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6020
# endif /* LINUX */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6021
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6022
# ifdef solaris
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6023
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6024
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6025
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6026
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6027
# endif /* solaris */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6028
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6029
# ifdef aix
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6030
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6031
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6032
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6033
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6034
# endif /* aix */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6035
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6036
# ifdef next3
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6037
#   define PTY_TEMPL    "/dev/ptyXX"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6038
#   define PT_INDEX      5
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6039
#   define PTY_1_CHARS  "pqr"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6040
#   define PTY_2_CHARS  "0123456789abcdef"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6041
# endif /* next3 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6042
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6043
# ifdef hpux
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6044
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6045
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6046
#   define PTY_1_CHARS  "pqrs"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6047
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6048
# endif /* hpux */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6049
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6050
# if defined(__osf__)
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6051
#   define PTY_TEMPL    "/dev/ptyXX"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6052
#   define PT_INDEX      5
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6053
#   define PTY_1_CHARS  "pq"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6054
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6055
# endif /* osf1 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6056
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6057
# if defined(BSD) && !defined(PTY_TEMPL)
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6058
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6059
#   define PT_INDEX      5
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6060
#   define PTY_1_CHARS  "p"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6061
#   define PTY_2_CHARS  "0123456789abcdefghijklmnopqrstuv"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6062
# endif /* BSD */
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
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6065
#   include <grp.h>
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6066
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6067
    static int ttygid = -2;
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6068
    char line[128];
3575
39723f691a0e hp-cc does not recognize const keyword
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
  6069
    register CONST char *cp1, *cp2;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6070
    int len, _fdM = -1, _fdS = -1;
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6071
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6072
    len = sizeof(PTY_TEMPL) - 1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6073
    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
  6074
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6075
    if (ttygid == -2) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6076
	struct group *gr;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6077
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6078
	if ((gr = getgrnam("tty")) != NULL)
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6079
	    ttygid = gr->gr_gid;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6080
	else
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6081
	    ttygid = -1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6082
    }
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6083
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6084
    for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6085
	line[len-2] = * cp1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6086
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6087
	for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6088
	    line[PT_INDEX] = 'p';
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6089
	    line[len-1] = *cp2;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6090
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6091
	    if ((_fdM = open(line, O_RDWR, 0)) < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6092
		if (errno == ENOENT) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6093
		    _fdM = _fdS = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6094
		    goto getOutOfHere; /* out of ptys */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6095
		}
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6096
	    } else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6097
		line[PT_INDEX] = 't';
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6098
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6099
		/*
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6100
		 * try to set owner and mode.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6101
		 * this works only if running under root
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6102
		 */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6103
		(void) chown( line, getuid(), ttygid );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6104
		(void) chmod( line, S_IRUSR | S_IWUSR | S_IWGRP );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6105
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6106
		if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6107
		    goto getOutOfHere; /* success */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6108
		}
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6109
		(void) close(_fdM );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6110
	    }
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6111
	}
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6112
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6113
  getOutOfHere: ;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6114
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6115
    if ((_fdM >= 0) && (_fdS >= 0)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6116
	 fdM = __MKSMALLINT(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6117
	 fdS = __MKSMALLINT(_fdS);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6118
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6119
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6120
#endif /* ! defined(PTY_IS_IMPLEMENTED) */
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6121
%}.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6122
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6123
    fdM notNil ifTrue:[
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6124
	^ Array with:fdM with:fdS.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6125
    ].
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6126
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6127
    ^ nil
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6128
!
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6129
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6130
makePipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6131
    "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
  6132
     nil on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6133
     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
  6134
     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
  6135
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6136
    |fd1 fd2|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6137
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6138
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6139
     int fds[2];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6141
     if (pipe(fds) < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6142
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6143
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6144
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6146
     fd1 = __MKSMALLINT(fds[0]);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6147
     fd2 = __MKSMALLINT(fds[1]);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6148
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6149
    fd1 notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6150
	^ Array with:fd1 with:fd2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6151
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6152
    ^ nil
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6153
!
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6154
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6155
resetTerminalInputOutputModes:fd
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6156
    "reset the terminal attributes"
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6157
%{
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6158
    struct termios switcher;
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6159
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6160
    printf("setMappingMaster fd:%d\n", __intVal(fd));
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6161
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6162
	if (tcgetattr( __intVal(fd), &switcher) < 0) RETURN (false);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6163
	switcher.c_iflag = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6164
	switcher.c_oflag = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6165
	if (tcsetattr( __intVal(fd), TCSANOW, &switcher) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6166
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6167
	}
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6168
    }
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6169
%}.
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6170
    ^ false
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6171
!
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6172
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6173
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
  6174
    "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
  6175
%{
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6176
#ifdef TIOCSWINSZ
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6177
    struct winsize wsize;
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6178
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6179
    if (__isSmallInteger(fd)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6180
     && __isSmallInteger(w)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6181
     && __isSmallInteger(h)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6182
	wsize.ws_row = (unsigned short)__intVal(h);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6183
	wsize.ws_col = (unsigned short)__intVal(w);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6184
	if (ioctl(__intVal(fd), TIOCSWINSZ, (char *)&wsize) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6185
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6186
	}
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6187
    }
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6188
#endif
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6189
%}.
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6190
    ^ false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6191
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6192
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6193
!UnixOperatingSystem class methodsFor:'misc'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6194
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6195
closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6196
    "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
  6197
     getAddrInfo implementation:
8469
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6198
        if it gets interrupted (via a timer, for example), its domain-name
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6199
        socket remains open and is NEVER closed.
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6200
        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
  6201
     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
  6202
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6203
    |p|
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6204
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6205
    p := PipeStream
8469
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6206
            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
  6207
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6208
    p linesDo:[:line |
8469
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6209
        |words fd|
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6210
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6211
        words := line asCollectionOfWords.
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6212
        "/ COMMAND PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6213
        words first = 'stx' ifTrue:[
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6214
            words second = (OperatingSystem getProcessId printString) ifTrue:[
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6215
                (words fourth endsWith:'u') ifTrue:[
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6216
                    (words fifth = 'IPv4') ifTrue:[
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6217
                        (words seventh = 'UDP') ifTrue:[
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6218
                            (words last endsWith:'domain') ifTrue:[
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6219
                                fd := Number readFrom:(words fourth copyWithoutLast:1).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6220
Transcript showCR:line.
8469
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6221
                                OperatingSystem closeFd:fd.
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6222
                            ]
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6223
                        ]
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6224
                    ]
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6225
                ]
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6226
            ]
928145276114 Remove #getStatusOfProcess: -- it does not work and can hang the system.
Stefan Vogel <sv@exept.de>
parents: 8355
diff changeset
  6227
        ]
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6228
    ].
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6229
    p close.
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6230
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6231
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6232
     self closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6233
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6234
!
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6235
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6236
closePid:pid
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  6237
    "free pid resource.
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  6238
     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
  6239
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6240
    ^ true.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6241
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6242
    "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
  6243
    "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
  6244
    "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
  6245
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6246
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6247
slowFork:aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6248
    "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
  6249
     Only used internally on SYSV3 systems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6250
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6251
    SlowFork := aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6252
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6253
    "Modified: 22.4.1996 / 13:13:09 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6254
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6255
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6256
!UnixOperatingSystem class methodsFor:'os queries'!
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
executableFileExtensions
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6259
    "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
  6260
     Only req'd for msdos like systems ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6261
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6262
    ^ #('')
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6263
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6264
    "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
  6265
    "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
  6266
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6267
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6268
getDomainName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6269
    "return the domain this host is in.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6270
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6271
	not all systems support this; on some, 'unknown' is returned."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6272
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6273
    |name idx hostName|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6274
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6275
    DomainName notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6276
	^ DomainName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6277
    ].
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6278
    name := self primGetDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6279
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6280
	"/ fallBack
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6281
	name := self getEnvironment:'DOMAIN'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6282
	name isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6283
	    name := self getCommandOutputFrom:'domainname'
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6284
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6285
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6286
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6287
	"/ sometimes, we can extract the domainName from the hostName ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6288
	hostName := self primGetHostName.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6289
	hostName notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6290
	    (hostName occurrencesOf:$.) == 1 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6291
		idx := hostName indexOf:$..
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6292
		idx ~~ 0 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6293
		    name := hostName copyFrom:idx+1.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6294
		]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6295
	    ]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6296
	].
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6297
	name isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6298
	    'UnixOperatingSystem [warning]: cannot find out domainname' errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6299
	    name := 'unknown'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6300
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6301
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6302
    DomainName := name.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6303
    ^ name
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6304
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6305
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6306
     OperatingSystem getDomainName
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6307
     OperatingSystem getHostName
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6308
     OperatingSystem primGetHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6309
    "
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
    "Modified: 26.4.1996 / 10:04:54 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6312
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6314
getEnvironment:aStringOrSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6315
    "get an environment string"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6316
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6317
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6318
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6319
    char *env;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6320
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6321
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  6322
    if (__isStringLike(aStringOrSymbol)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6323
	env =  getenv(__stringVal(aStringOrSymbol));
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6324
	if (env) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6325
	    RETURN ( __MKSTRING(env) );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6326
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6327
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6328
    }
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6329
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  6330
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6332
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6333
     OperatingSystem getEnvironment:'LANG'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6334
     OperatingSystem getEnvironment:'LOGIN'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6335
     OperatingSystem getEnvironment:'HOME'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6336
     OperatingSystem getEnvironment:'NNTPSERVER'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6337
     OperatingSystem getEnvironment:'MAIL'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6338
     OperatingSystem getEnvironment:'PATH'
3496
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6341
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6342
getHostName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6343
    "return the hostname we are running on - if there is
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6344
     a HOST environment variable, we are much faster here ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6345
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6346
	not all systems support this; on some, 'unknown' is returned."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6347
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6348
    |name idx|
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
    HostName notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6351
	^ HostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6352
    ].
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6353
    name := self primGetHostName.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6354
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6355
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6356
	"/ fallBack
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6357
	name := self getEnvironment:'HOST'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6358
	name isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6359
	    name := self getCommandOutputFrom:'hostname'
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6360
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6361
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6362
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6363
	'UnixOperatingSystem [warning]: cannot find out hostname' errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6364
	name := 'unknown'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6365
    ] ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6366
	"/ on some systems, the hostname already contains the domain.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6367
	"/ decompose it here.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6368
	(name occurrencesOf:$.) == 1 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6369
	    idx := name indexOf:$..
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6370
	    idx ~~ 0 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6371
		DomainName := name copyFrom:(idx+1).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6372
		name := name copyTo:(idx-1).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6373
	    ]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6374
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6375
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6376
    HostName := name.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6377
    ^ name
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6378
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6379
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6380
     OperatingSystem getHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6381
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6382
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6383
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6384
getLocaleInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6385
    "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
  6386
     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
  6387
     Possible fields are:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6388
	decimalPoint                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6389
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6390
	thousandsSep                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6391
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6392
	internationalCurrencySymbol     <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6393
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6394
	currencySymbol                  <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6395
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6396
	monetaryDecimalPoint            <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6397
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6398
	monetaryThousandsSeparator      <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6399
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6400
	positiveSign                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6401
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6402
	negativeSign                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6403
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6404
	internationalFractionalDigits   <Integer>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6405
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6406
	fractionalDigits                <Integer>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6407
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6408
	positiveSignPrecedesCurrencySymbol      <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6409
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6410
	negativeSignPrecedesCurrencySymbol      <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6411
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6412
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6413
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6414
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6415
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6416
	positiveSignPosition                            <Symbol>
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6417
							one of: #parenthesesAround,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6418
								#signPrecedes,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6419
								#signSuceeds,
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6420
								#signPrecedesCurrencySymbol,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6421
								#signSuceedsCurrencySymbol
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6422
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6423
	negativeSignPosition                            <like above>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6424
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6425
     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
  6426
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6427
     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
  6428
     it should be used by applications as required.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6429
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6430
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6431
    |info val|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6432
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6433
    LocaleInfo notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6434
	"/ return the internal info; useful on systems which do not
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6435
	"/ support this.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6436
	^ LocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6437
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6438
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6439
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6440
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6441
    char *decimalPoint;         /* something like "." (US) or "," (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6442
    char *thousandsSep;         /* something like "," (US) or "." (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6443
    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
  6444
    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
  6445
    char *monDecimalPoint;      /* money: decimal point */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6446
    char *monThousandsSep;      /* money: thousands sep */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6447
    char *positiveSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6448
    char *negativeSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6449
    int   intFractDigits;       /* money: international digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6450
    int   fractDigits;          /* money: local digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6451
    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
  6452
    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
  6453
    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
  6454
    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
  6455
    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
  6456
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6457
				/*        2: sign succeeds the value & currency symbol */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6458
				/*        3: sign immediately precedes the currency symbol */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6459
				/*        4: sign immediately suceeds the currency symbol */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6460
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6461
#if defined(HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6462
    struct lconv *conf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6463
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6464
    conf = localeconv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6465
    if (conf) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6466
	decimalPoint = conf->decimal_point;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6467
	thousandsSep = conf->thousands_sep;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6468
	intCurrencySymbol = conf->int_curr_symbol;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6469
	currencySymbol = conf->currency_symbol;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6470
	monDecimalPoint = conf->mon_decimal_point;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6471
	monThousandsSep = conf->mon_thousands_sep;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6472
	positiveSign = conf->positive_sign;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6473
	negativeSign = conf->negative_sign;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6474
	intFractDigits = conf->int_frac_digits;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6475
	fractDigits = conf->frac_digits;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6476
	csPosPrecedes = conf->p_cs_precedes;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6477
	csNegPrecedes = conf->n_cs_precedes;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6478
	csPosSepBySpace = conf->p_sep_by_space;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6479
	csNegSepBySpace = conf->n_sep_by_space;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6480
	csPosSignPosition = conf->p_sign_posn;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6481
	csNegSignPosition = conf->n_sign_posn;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6482
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6483
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6484
    decimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6485
    thousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6486
    intCurrencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6487
    currencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6488
    monDecimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6489
    monThousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6490
    positiveSign =  (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6491
    negativeSign =(char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6492
    intFractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6493
    fractDigits = -1;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6494
    csPosPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6495
    csNegPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6496
    csPosSepBySpace = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6497
    csNegSepBySpace = -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6498
    csPosSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6499
    csNegSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6500
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6501
    if (decimalPoint) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6502
	val = __MKSTRING(decimalPoint);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6503
	__AT_PUT_(info, @symbol(decimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6504
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6505
    if (thousandsSep) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6506
	val = __MKSTRING(thousandsSep);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6507
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6508
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6509
    if (intCurrencySymbol) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6510
	val = __MKSTRING(intCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6511
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6512
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6513
    if (currencySymbol) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6514
	val = __MKSTRING(currencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6515
	__AT_PUT_(info, @symbol(currencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6516
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6517
    if (monDecimalPoint) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6518
	val = __MKSTRING(monDecimalPoint);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6519
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6520
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6521
    if (monThousandsSep) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6522
	val = __MKSTRING(monThousandsSep);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6523
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6524
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6525
    if (positiveSign) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6526
	val = __MKSTRING(positiveSign);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6527
	__AT_PUT_(info, @symbol(positiveSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6528
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6529
    if (negativeSign) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6530
	val = __MKSTRING(negativeSign);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6531
	__AT_PUT_(info, @symbol(negativeSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6532
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6533
    if (intFractDigits >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6534
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __MKSMALLINT(intFractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6535
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6536
    if (fractDigits >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6537
	__AT_PUT_(info, @symbol(fractionalDigits),  __MKSMALLINT(fractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6538
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6539
    if (csPosPrecedes >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6540
	if (csPosPrecedes == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6541
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6542
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6543
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6544
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6545
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6546
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6547
    if (csNegPrecedes >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6548
	if (csNegPrecedes == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6549
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6550
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6551
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6552
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6553
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6554
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6555
    if (csPosSepBySpace >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6556
	if (csPosSepBySpace == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6557
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6558
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6559
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6560
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6561
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6562
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6563
    if (csNegSepBySpace >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6564
	if (csNegSepBySpace == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6565
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6566
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6567
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6568
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6569
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6570
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6571
    switch (csPosSignPosition) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6572
	case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6573
	    val = @symbol(parenthesesAround);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6574
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6575
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6576
	case 1:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6577
	    val = @symbol(signPrecedes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6578
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6579
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6580
	case 2:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6581
	    val = @symbol(signSuceeds);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6582
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6583
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6584
	case 3:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6585
	    val = @symbol(signPrecedesCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6586
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6587
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6588
	case 4:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6589
	    val = @symbol(signSuceedsCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6590
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6591
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6592
	default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6593
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6594
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6595
    if (val != nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6596
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6597
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6599
    switch (csNegSignPosition) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6600
	case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6601
	    val = @symbol(parenthesesAround);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6602
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6603
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6604
	case 1:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6605
	    val = @symbol(signPrecedes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6606
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6607
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6608
	case 2:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6609
	    val = @symbol(signSuceeds);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6610
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6611
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6612
	case 3:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6613
	    val = @symbol(signPrecedesCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6614
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6615
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6616
	case 4:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6617
	    val = @symbol(signSuceedsCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6618
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6619
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6620
	default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6621
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6622
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6623
    if (val != nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6624
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6625
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6626
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6627
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6628
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6629
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6630
     OperatingSystem getLocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6631
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6632
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6633
    "Created: 23.12.1995 / 14:19:20 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6634
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6635
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6636
getNetworkMACAddresses
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6637
    "return a dictionary filled with
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6638
	key -> name of interface
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6639
	value -> the MAC adress (as ByteArray)
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6640
     for each interface"
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6641
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6642
    |addressArray nameArray noOfIf retDictionary error|
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6643
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6644
    noOfIf := 0.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6645
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6646
%{
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6647
#ifdef SIOCGIFHWADDR
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6648
    int             afinet_socket = -1;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6649
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6650
    struct ifconf   ifc;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6651
    struct ifreq    *ifr;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6652
    struct ifreq    ifreq;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6653
    unsigned char   buf[1024];
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6654
    int             n_ifs, i, countOfIf;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6655
    OBJ             t;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6656
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6657
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6658
    ** Open an INET socket
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6659
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6660
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6661
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6662
    if (afinet_socket < 0) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6663
	error = __MKSTRING("Cannot open socket");
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6664
	goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6665
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6666
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6667
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6668
    ** Get the list of network interfaces
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6669
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6670
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6671
    ifc.ifc_len = sizeof (buf);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6672
    ifc.ifc_buf = (caddr_t) buf;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6673
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6674
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6675
	close(afinet_socket);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6676
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6677
	goto bad;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6678
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6679
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6680
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6681
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6682
    nameArray    = __MKARRAY(n_ifs);
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6683
    addressArray = __MKARRAY(n_ifs);
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6684
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6685
    if (nameArray == nil || addressArray == nil) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6686
	/* Creating a string wouldn/t work here */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6687
	error = @symbol(allocationFailure);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6688
	goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6689
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6690
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6691
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6692
    ** Iterate of the list of the system's netif. Find all
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6693
    ** active interfaces and their ethernet addresses
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6694
    */
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6695
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6696
    countOfIf = 0;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6697
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6698
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6699
	/*
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6700
	** Get Flags for this interface
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6701
	*/
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6702
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6703
	memcpy(&ifreq, ifr, sizeof(ifreq));
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6704
	if (ioctl (afinet_socket, SIOCGIFFLAGS, &ifreq) < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6705
	    fprintf(stderr, "ioctl(SIOCGIFFLAGS) failed");
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6706
	} else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6707
	    /*
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6708
	    ** Get Hardware address for this interface
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6709
	    */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6710
	    memcpy(&ifreq, ifr, sizeof(ifreq));
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6711
	    if (ioctl (afinet_socket, SIOCGIFHWADDR, &ifreq) >= 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6712
		t = __MKBYTEARRAY(&ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6713
		__arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6714
		t = __MKSTRING(&ifreq.ifr_ifrn.ifrn_name, IFNAMSIZ);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6715
		__arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6716
		countOfIf += 1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6717
	    }
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6718
	}
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6719
    }
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6720
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6721
    noOfIf = __mkSmallInteger(countOfIf);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6722
bad:
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6723
    if (afinet_socket >= 0)
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6724
	close(afinet_socket);
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6725
#else
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6726
    error = @symbol(notSupported);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6727
#endif /* SIOCGIFHWADDR */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6728
%}.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6729
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6730
    retDictionary := Dictionary new:noOfIf.
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6731
    error notNil ifTrue:[
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6732
	self primitiveFailed:error.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6733
	"return empty dictionary if proceed from error"
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6734
	^  retDictionary.
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6735
    ].
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6736
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6737
    1 to:noOfIf do:[:cnt|
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6738
	retDictionary at:(nameArray at:cnt) put:(addressArray at:cnt).
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6739
    ].
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6740
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6741
    ^ retDictionary
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6742
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6743
    "
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6744
      OperatingSystem getNetworkMACAddresses
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  6745
    "
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  6746
!
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  6747
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6748
getProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6749
    "return the (unix-)processId"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6750
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6751
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6752
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6753
    int pid = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6755
    pid = getpid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6756
    RETURN ( __MKSMALLINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6757
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6758
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6759
     OperatingSystem getProcessId
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6760
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6761
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6763
getSystemID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6764
    "if supported by the OS, return the systemID;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6765
     a unique per machine identification.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6766
     WARNING:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6767
	not all systems support this; on some, 'unknown' is returned."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6768
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6769
%{  /* NO_CONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6770
#if defined(IRIX5) && !defined(HAS_GETHOSTID)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6771
    char idBuffer[MAXSYSIDSIZE];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6772
    int retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6773
    OBJ arr;
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
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6776
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6777
	bcopy(idBuffer, __byteArrayVal(arr), MAXSYSIDSIZE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6778
	RETURN (arr);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6781
#if defined(HAS_GETHOSTID)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6782
    int runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6783
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6784
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6785
    runningId = gethostid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6786
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6787
    *(int *)(__byteArrayVal(arr)) = runningId;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6788
    RETURN (arr);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6789
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6790
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6791
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6792
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6793
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6794
	buffer[0] = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6795
	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6796
	    buffer[127] = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6797
	    if (strlen(buffer) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6798
		RETURN(__MKSTRING(buffer));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6799
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6800
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6801
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6802
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6803
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6804
    ^ 'unknown'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6805
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6806
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6807
     OperatingSystem getSystemID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6808
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6809
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6810
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6811
getSystemInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6812
    "return info on the system weare running on.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6813
     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
  6814
     otherwise, some simulated info is returned.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6815
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6816
     WARNING:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6817
       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
  6818
       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
  6819
       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
  6820
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6821
       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
  6822
       information.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6823
       (in case of system/version specific OS errors, conditional workarounds and patches
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6824
	may be based upon this info).
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6825
       Also, applications could enable/disable buffering or otherwise reduce
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6826
       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
  6827
       Your application may make use of available information for tuning,
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6828
       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
  6829
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6830
     The returned info may (or may not) contain:
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6831
	#system -> some operating system identification (irix, Linux, nt, win32s ...)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6832
	#version -> OS version (some os version identification)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6833
	#release -> OS release (3.5, 1.2.1 ...)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6834
	#node   -> some host identification (hostname)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6835
	#domain  -> domain name (hosts domain)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6836
	#machine -> type of CPU (i586, mips ...)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6837
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6838
     those are currently returned on some machines (no warranty)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6839
     linux:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6840
	#totalRam         -> total amount of memory available
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6841
	#sharedRam        -> amount of memory which is shared among processes
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6842
			     (i.e. shared code)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6843
	#bufferRam        -> amount used for buffers
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6844
	#swapSize         -> total size of swap space
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6845
	#freeSwap         -> free amount in swapSpace
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6846
	#extendedInstructions -> extended instruction set info
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6847
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6848
     osf:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6849
	#physicalRam      -> total amount of physical memory
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6850
	#cpuType          -> type of cpu (more detailed than machine)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6851
	#numberOfCPUs     -> number of cpus in box
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6852
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6853
     solaris:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6854
	#physicalRam      -> total amount of physical memory
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6855
	#availableRam     -> total available amount of physical memory (i.e. unused ram)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6856
	#freeRam          -> amount of free memory
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6857
	#numberOfCPUs     -> number of cpus in box (online CPUS)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6858
	[#dCacheSize]     -> bytes in data cache (only available on some solaris versions)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6859
	[#iCacheSize]     -> bytes in data cache (only available on some solaris versions)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6860
	[#instructionSets]-> instruction sets available (only available on some solaris versions)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6861
	[#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
  6862
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6863
     hpux:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6864
	#physicalRam      -> total amount of physical memory in box
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6865
	#activeRealMemory -> ? - read pstat documentation
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6866
	#activeVirtualRam -> ? - read pstat documentation
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6867
	#freeMemory       -> ? - read pstat documentation
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6868
	#realMemory       -> ? (amount of memory left to user programs)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6869
	#virtualRam       -> ? - read pstat documentation
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6870
    "
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6871
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6872
    |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
  6873
     physicalRam availableRam totalRam sharedRam bufferRam swapSize freeSwap
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6874
     numberOfCPUs pageSize physicalPages availablePages dCacheSize iCacheSize
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6875
     virtualRam activeVirtualRam realMemory activeRealMemory freeMemory
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6876
     instructionSets extendedInstructions platform|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6877
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6878
%{  /* STACK: 4096 */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6879
#ifdef LINUX
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  6880
# 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
  6881
    /*
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6882
     * additional info available ...
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6883
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6884
    struct sysinfo infoBuffer;
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6885
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6886
    if (sysinfo(&infoBuffer) >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6887
	totalRam   = __MKUINT(infoBuffer.totalram);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6888
	sharedRam = __MKUINT(infoBuffer.sharedram);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6889
	bufferRam = __MKUINT(infoBuffer.bufferram);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6890
	swapSize  = __MKUINT(infoBuffer.totalswap);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6891
	freeSwap  = __MKUINT(infoBuffer.freeswap);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6892
    }
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  6893
# endif
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6894
#endif /* LINUX */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6895
4088
622551d3c0d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  6896
#if defined(hpux) && !defined(__GNUC__)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6897
# include <sys/pstat.h>
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6898
    struct pst_static stat_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6899
    struct pst_dynamic dynam_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6900
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6901
    pstat(PSTAT_STATIC,&stat_buf,sizeof(stat_buf),0,0);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6902
    pstat(PSTAT_DYNAMIC,&dynam_buf,sizeof(dynam_buf),0,0);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6903
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6904
    physicalRam        = __MKUINT(stat_buf.physical_memory/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6905
    virtualRam         = __MKUINT(dynam_buf.psd_vm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6906
    activeVirtualRam   = __MKUINT(dynam_buf.psd_avm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6907
    realMemory         = __MKUINT(dynam_buf.psd_rm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6908
    activeRealMemory   = __MKUINT(dynam_buf.psd_arm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6909
    freeMemory         = __MKUINT(dynam_buf.psd_free/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6910
#endif
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6911
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6912
#if defined(HAS_UNAME)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6913
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6914
	struct utsname ubuff;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6915
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6916
	if (uname(&ubuff) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6917
	    sys  = __MKSTRING(ubuff.sysname);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6918
	    node = __MKSTRING(ubuff.nodename);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6919
	    rel  = __MKSTRING(ubuff.release);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6920
	    ver  = __MKSTRING(ubuff.version);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6921
	    mach = __MKSTRING(ubuff.machine);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6922
# ifdef HAS_UTS_DOMAINNAME
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6923
	    dom  = __MKSTRING(ubuff.domainname);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6924
# endif /* no HAS_UTS_DOMAINNAME */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6925
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6926
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6927
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6928
#else /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6929
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6930
    /*
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6931
     * use fallBack code below
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6932
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6933
#endif /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6934
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6935
#if defined(HAS_SYSINFO)
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6936
# if defined(SI_ARCHITECTURE)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6937
    if (arch == nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6938
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6939
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6940
	if (sysinfo(SI_ARCHITECTURE, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6941
	    arch = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6942
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6943
    }
4923
1cacdcfc82c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4922
diff changeset
  6944
# endif /* SI_ARCHITECTURE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6945
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6946
# if defined(SI_ISALIST)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6947
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6948
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6949
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6950
	if (sysinfo(SI_ISALIST, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6951
	    instructionSets = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6952
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6953
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6954
# endif /* SI_ISALIST */
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6955
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6956
# if defined(SI_PLATFORM)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6957
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6958
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6959
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6960
	if (sysinfo(SI_PLATFORM, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6961
	    platform = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6962
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6963
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6964
# endif /* SI_PLATFORM */
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6965
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6966
# if defined(SI_RELEASE)
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6967
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6968
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6969
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6970
	if (sysinfo(SI_RELEASE, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6971
	    rel = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6972
	}
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6973
    }
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6974
# endif /* SI_RELEASE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6975
#endif /* HAS_SYSINFO */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6976
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6977
#if defined(HAS_GETDOMAINNAME)
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6978
    if (dom == nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6979
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6980
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6981
	if (getdomainname(buffer, sizeof(buffer)) == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6982
	    dom = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6983
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6984
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6985
#endif /* HAS_GETDOMAINNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6986
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6987
#if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6988
# ifdef _SC_NPROCESSORS_ONLN
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6989
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6990
	long val;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6991
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6992
	val = sysconf(_SC_NPROCESSORS_ONLN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6993
	if (val > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6994
	    numberOfCPUs = __MKINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6995
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6996
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6997
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6998
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6999
# if defined(_SC_PAGESIZE)
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7000
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7001
	long val;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7002
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7003
	val = sysconf(_SC_PAGESIZE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7004
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7005
	    pageSize = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7006
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7007
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7008
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7009
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7010
# if defined(_SC_PHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7011
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7012
	long val;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7013
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7014
	val = sysconf(_SC_PHYS_PAGES);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7015
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7016
	    physicalPages = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7017
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7018
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7019
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7020
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7021
# if defined(_SC_AVPHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7022
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7023
	long val;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7024
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7025
	val = sysconf(_SC_AVPHYS_PAGES);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7026
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7027
	    availablePages = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7028
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7029
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7030
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7031
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7032
# if defined(_SC_ICACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7033
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7034
	long val;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7035
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7036
	val = sysconf(_SC_ICACHE_SZ);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7037
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7038
	    iCacheSize = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7039
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7040
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7041
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7042
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7043
# if defined(_SC_DCACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7044
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7045
	long val;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7046
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7047
	val = sysconf(_SC_DCACHE_SZ);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7048
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7049
	    dCacheSize = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7050
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7051
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7052
# endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7053
#endif /* HAS_SYSCONF */
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7054
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7055
#if defined(HAS_GETSYSINFO)
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7056
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7057
	INT index;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7058
	int retInt32 = 0;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7059
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7060
# if defined(GSI_CPU)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7061
	index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7062
	if (getsysinfo(GSI_CPU, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7063
	    switch (retInt32) {
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7064
#  ifdef VAX_780
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7065
		case VAX_780:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7066
		    cpuType = __MKSTRING("VAX_780");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7067
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7068
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7069
#  ifdef VAX_750
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7070
		case VAX_750:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7071
		    cpuType = __MKSTRING("VAX_750");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7072
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7073
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7074
#  ifdef VAX_730
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7075
		case VAX_730:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7076
		    cpuType = __MKSTRING("VAX_730");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7077
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7078
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7079
#  ifdef VAX_8600
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7080
		case VAX_8600:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7081
		    cpuType = __MKSTRING("VAX_8600");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7082
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7083
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7084
#  ifdef VAX_8200
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7085
		case VAX_8200:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7086
		    cpuType = __MKSTRING("VAX_8200");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7087
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7088
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7089
#  ifdef VAX_8800
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7090
		case VAX_8800:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7091
		    cpuType = __MKSTRING("VAX_8800");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7092
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7093
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7094
#  ifdef MVAX_I
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7095
		case MVAX_I:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7096
		    cpuType = __MKSTRING("MVAX_I");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7097
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7098
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7099
#  ifdef MVAX_II
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7100
		case MVAX_II:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7101
		    cpuType = __MKSTRING("MVAX_II");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7102
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7103
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7104
#  ifdef V_VAX
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7105
		case V_VAX:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7106
		    cpuType = __MKSTRING("V_VAX");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7107
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7108
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7109
#  ifdef VAX_3600
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7110
		case VAX_3600:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7111
		    cpuType = __MKSTRING("VAX_3600");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7112
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7113
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7114
#  ifdef VAX_6200
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7115
		case VAX_6200:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7116
		    cpuType = __MKSTRING("VAX_6200");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7117
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7118
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7119
#  ifdef VAX_3400
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7120
		case VAX_3400:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7121
		    cpuType = __MKSTRING("VAX_3400");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7122
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7123
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7124
#  ifdef C_VAXSTAR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7125
		case C_VAXSTAR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7126
		    cpuType = __MKSTRING("C_VAXSTAR");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7127
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7128
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7129
#  ifdef VAX_60
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7130
		case VAX_60:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7131
		    cpuType = __MKSTRING("VAX_60");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7132
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7133
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7134
#  ifdef VAX_3900
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7135
		case VAX_3900:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7136
		    cpuType = __MKSTRING("VAX_3900");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7137
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7138
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7139
#  ifdef DS_3100
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7140
		case DS_3100:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7141
		    cpuType = __MKSTRING("DS_3100");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7142
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7143
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7144
#  ifdef VAX_8820
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7145
		case VAX_8820:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7146
		    cpuType = __MKSTRING("VAX_8820");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7147
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7148
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7149
#  ifdef DS_5400
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7150
		case DS_5400:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7151
		    cpuType = __MKSTRING("DS_5400");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7152
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7153
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7154
#  ifdef DS_5800
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7155
		case DS_5800:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7156
		    cpuType = __MKSTRING("DS_5800");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7157
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7158
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7159
#  ifdef DS_5000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7160
		case DS_5000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7161
		    cpuType = __MKSTRING("DS_5000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7162
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7163
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7164
#  ifdef DS_CMAX
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7165
		case DS_CMAX:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7166
		    cpuType = __MKSTRING("DS_CMAX");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7167
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7168
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7169
#  ifdef VAX_6400
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7170
		case VAX_6400:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7171
		    cpuType = __MKSTRING("VAX_6400");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7172
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7173
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7174
#  ifdef VAXSTAR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7175
		case VAXSTAR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7176
		    cpuType = __MKSTRING("VAXSTAR");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7177
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7178
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7179
#  ifdef DS_5500
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7180
		case DS_5500:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7181
		    cpuType = __MKSTRING("DS_5500");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7182
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7183
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7184
#  ifdef DS_5100
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7185
		case DS_5100:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7186
		    cpuType = __MKSTRING("DS_5100");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7187
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7188
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7189
#  ifdef VAX_9000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7190
		case VAX_9000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7191
		    cpuType = __MKSTRING("VAX_9000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7192
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7193
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7194
#  ifdef DS_500_100
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7195
		case DS_500_100:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7196
		    cpuType = __MKSTRING("DS_500_100");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7197
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7198
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7199
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7200
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7201
#  ifdef ALPHA_ADU
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7202
		case ALPHA_ADU:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7203
		    cpuType = __MKSTRING("ALPHA_ADU");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7204
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7205
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7206
#  ifdef DEC_4000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7207
		case DEC_4000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7208
		    cpuType = __MKSTRING("DEC_4000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7209
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7210
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7211
#  ifdef DEC_3000_500
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7212
		case DEC_3000_500:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7213
		    cpuType = __MKSTRING("DEC_3000_500");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7214
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7215
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7216
#  ifdef DEC_7000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7217
		case DEC_7000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7218
		    cpuType = __MKSTRING("DEC_7000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7219
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7220
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7221
#  ifdef DS_5000_300
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7222
		case DS_5000_300:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7223
		    cpuType = __MKSTRING("DS_5000_300");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7224
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7225
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7226
#  ifdef DEC_3000_300
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7227
		case DEC_3000_300:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7228
		    cpuType = __MKSTRING("DEC_3000_300");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7229
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7230
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7231
#  ifdef DEC_2000_300
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7232
		case DEC_2000_300:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7233
		    cpuType = __MKSTRING("DEC_2000_300");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7234
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7235
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7236
#  ifdef DEC_2100_A500
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7237
		case DEC_2100_A500:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7238
		    cpuType = __MKSTRING("DEC_2100_A500");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7239
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7240
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7241
#  ifdef DEC_2100_A50
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7242
		case DEC_2100_A50:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7243
		    cpuType = __MKSTRING("DEC_2100_A50");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7244
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7245
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7246
#  ifdef ALPHA_KN20AA
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7247
		case ALPHA_KN20AA:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7248
		    cpuType = __MKSTRING("ALPHA_KN20AA");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7249
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7250
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7251
#  ifdef DEC_21000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7252
		case DEC_21000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7253
		    cpuType = __MKSTRING("DEC_21000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7254
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7255
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7256
#  ifdef DEC_AXPVME_64
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7257
		case DEC_AXPVME_64:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7258
		    cpuType = __MKSTRING("DEC_AXPVME_64");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7259
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7260
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7261
#  ifdef DEC_2100_C500
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7262
		case DEC_2100_C500:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7263
		    cpuType = __MKSTRING("DEC_2100_C500");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7264
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7265
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7266
#  ifdef DEC_AXPPCI_33
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7267
		case DEC_AXPPCI_33:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7268
		    cpuType = __MKSTRING("DEC_AXPPCI_33");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7269
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7270
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7271
#  ifdef DEC_1000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7272
		case DEC_1000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7273
		    cpuType = __MKSTRING("DEC_1000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7274
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7275
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7276
#  ifdef EB64_PLUS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7277
		case EB64_PLUS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7278
		    cpuType = __MKSTRING("EB64_PLUS");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7279
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7280
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7281
#  ifdef LCA_EB66
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7282
		case LCA_EB66:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7283
		    cpuType = __MKSTRING("LCA_EB66");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7284
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7285
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7286
#  ifdef ALPHA_EB164
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7287
		case ALPHA_EB164:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7288
		    cpuType = __MKSTRING("ALPHA_EB164");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7289
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7290
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7291
#  ifdef DEC_EV45_PBP
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7292
		case DEC_EV45_PBP:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7293
		    cpuType = __MKSTRING("DEC_EV45_PBP");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7294
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7295
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7296
#  ifdef DEC_1000A
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7297
		case DEC_1000A:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7298
		    cpuType = __MKSTRING("DEC_1000A");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7299
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7300
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7301
#  ifdef DEC_4100
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7302
		case DEC_4100:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7303
		    cpuType = __MKSTRING("DEC_4100");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7304
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7305
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7306
#  ifdef DEC_ALPHAVME_224
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7307
		case DEC_ALPHAVME_224:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7308
		    cpuType = __MKSTRING("DEC_ALPHAVME_224");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7309
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7310
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7311
#  ifdef DEC_1000_5
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7312
		case DEC_1000_5:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7313
		    cpuType = __MKSTRING("DEC_1000_5");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7314
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7315
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7316
#  ifdef DEC_1000A_5
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7317
		case DEC_1000A_5:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7318
		    cpuType = __MKSTRING("DEC_1000A_5");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7319
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7320
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7321
#  ifdef DEC_EV56_PBP
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7322
		case DEC_EV56_PBP:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7323
		    cpuType = __MKSTRING("DEC_EV56_PBP");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7324
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7325
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7326
#  ifdef ALPHABOOK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7327
		case ALPHABOOK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7328
		    cpuType = __MKSTRING("ALPHABOOK");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7329
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7330
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7331
#  ifdef DEC_ALPHAVME_320
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7332
		case DEC_ALPHAVME_320:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7333
		    cpuType = __MKSTRING("DEC_ALPHAVME_320");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7334
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7335
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7336
#  ifdef DEC_550
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7337
		case DEC_550:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7338
		    cpuType = __MKSTRING("DEC_550");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7339
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7340
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7341
#  ifdef DEC_6600
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7342
		case DEC_6600:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7343
		    cpuType = __MKSTRING("DEC_6600");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7344
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7345
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7346
#  ifdef UNKN_SYSTEM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7347
		case UNKN_SYSTEM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7348
		    cpuType = __MKSTRING("UNKN_SYSTEM");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7349
		    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7350
#  endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7351
		default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7352
		    cpuType = __MKSTRING("OTHER_DEC_SYSTEM");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7353
		    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7354
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7355
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7356
# endif /* GSI_CPU */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7357
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7358
# if defined(GSI_CPU_INFO)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7359
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7360
	 * stupid: OSF1 pre V4.0 has no mhz, but V4.0 has it.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7361
	 * use the GSI_PLATFORM_NAME as a hint - it is only defined in
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7362
	 * V4.0 and higher ... (sigh)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7363
	 */
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7364
#  if defined GSI_PLATFORM_NAME
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7365
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7366
	    struct cpu_info cpuInfo;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7367
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7368
	    index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7369
	    if (getsysinfo(GSI_CPU_INFO, &cpuInfo, sizeof(cpuInfo), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7370
		cpuSpeed   = __MKUINT(cpuInfo.mhz);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7371
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7372
	}
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7373
#  endif
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7374
# endif /* GSI_CPU_INFO */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7375
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7376
# if defined(GSI_CPUS_IN_BOX)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7377
	index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7378
	if (getsysinfo(GSI_CPUS_IN_BOX, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7379
	    numberOfCPUs   = __MKUINT(retInt32);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7380
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7381
# endif /* GSI_CPUS_IN_BOX */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7382
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7383
# if defined(GSI_PHYSMEM)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7384
	index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7385
	if (getsysinfo(GSI_PHYSMEM, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7386
	    INT bytes = retInt32 * 1024;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7387
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7388
	    physicalRam   = __MKUINT(bytes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7389
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7390
# endif /* GSI_PHYSMEM */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7391
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7392
# if defined(GSI_PLATFORM_NAME) && (!defined(HAS_SYSINFO) || !defined(SI_PLATFORM))
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7393
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7394
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7395
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7396
	index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7397
	if (getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7398
	    platform = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7399
	}
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7400
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7401
# endif /* GSI_PLATFORM_NAME */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7402
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7403
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7404
#endif /* HAS_GETSYSINFO */
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7405
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7406
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7407
	extern OBJ __getInstructionSetInfo();
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7408
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7409
	extendedInstructions = __getInstructionSetInfo();
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7410
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7411
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7412
    sys isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7413
	sys := self getSystemType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7414
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7415
    node isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7416
	node := self getHostName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7417
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7418
    dom isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7419
	dom := self getDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7420
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7421
    mach isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7422
	mach := self getCPUType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7423
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7424
    arch isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7425
	arch := sys.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7426
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7427
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7428
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7429
    info at:#system put:sys.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7430
    info at:#node put:node.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7431
    rel notNil ifTrue:[info at:#release put:rel].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7432
    ver notNil ifTrue:[info at:#version put:ver].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7433
    mach notNil ifTrue:[info at:#machine put:mach].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7434
    arch notNil ifTrue:[info at:#architecture put:arch].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7435
    dom notNil ifTrue:[info at:#domain put:dom].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7436
    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7437
	physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7438
    ].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7439
    physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7440
    (pageSize notNil and:[availablePages notNil]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7441
	availableRam := pageSize * availablePages. "/ done here - could be largeInt.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7442
	availableRam notNil ifTrue:[info at:#availableRam put:availableRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7443
    ].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7444
    totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7445
    sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7446
    bufferRam notNil ifTrue:[info at:#bufferRam put:bufferRam].
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7447
    virtualRam notNil ifTrue:[info at:#virtualRam put:virtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7448
    activeVirtualRam notNil ifTrue:[info at:#activeVirtualRam put:activeVirtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7449
    realMemory notNil ifTrue:[info at:#realMemory put:realMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7450
    activeRealMemory notNil ifTrue:[info at:#activeRealMemory put:activeRealMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7451
    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
  7452
    swapSize notNil ifTrue:[info at:#swapSize put:swapSize].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7453
    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
  7454
    numberOfCPUs notNil ifTrue:[info at:#numberOfCPUs put:numberOfCPUs].
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7455
    cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7456
    cpuSpeed notNil ifTrue:[info at:#cpuSpeed put:cpuSpeed].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7457
    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7458
    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7459
    instructionSets notNil ifTrue:[info at:#instructionSets put:instructionSets].
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7460
    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
  7461
    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
  7462
    info at:#osType put:(self getOSType).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7463
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7464
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7465
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7466
     OperatingSystem getSystemInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7467
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7468
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7469
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7470
getSystemType
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7471
    "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
  7472
     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
  7473
     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
  7474
     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
  7475
     here ...
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7476
     (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
  7477
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7478
    |sys|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7479
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7480
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7481
#   ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7482
#    define SYS_STRING "next"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7483
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7484
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7485
#   ifdef IRIS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7486
#    define SYS_STRING "iris"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7487
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7488
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7489
#   ifdef SYS_STRING
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7490
     sys = __MKSTRING(SYS_STRING);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7491
#    undef SYS_STRING
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7492
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7493
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7494
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7495
    sys isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7496
	^ self getOSType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7497
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7498
    ^ sys
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7499
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7500
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7501
     OperatingSystem getSystemType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7502
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7503
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7504
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7505
isBSDlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7506
    "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
  7507
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7508
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7509
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7510
#if defined(BSD) || defined(MACH) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7511
    RETURN ( true );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7512
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7513
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7514
    ^ false
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7515
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7516
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7517
     OperatingSystem isBSDlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7518
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7519
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7520
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7521
isUNIXlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7522
    "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
  7523
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7524
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7525
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7526
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7527
     OperatingSystem isUNIXlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7528
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7529
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7530
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7531
maxFileNameLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7532
    "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
  7533
     CAVEAT:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7534
	 Actually, the following is somewhat wrong - some systems
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7535
	 support different sizes, depending on the volume.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7536
	 We return a somewhat conservative number here.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7537
	 Another entry, to query for volume specific max
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7538
	 will be added in the future."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7539
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7540
%{  /* NOCONTEXT */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7541
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7542
    /*
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7543
     * 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
  7544
     */
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7545
#   if defined(MAXFILENAMELEN)
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7546
      RETURN ( __MKSMALLINT(MAXFILENAMELEN) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7547
#   else
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7548
#    if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7549
      RETURN ( __MKSMALLINT(255) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7550
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7551
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7552
#    ifdef realIX
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7553
       RETURN ( __MKSMALLINT(127) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7554
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7555
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7556
#    ifdef SYSV
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7557
       RETURN ( __MKSMALLINT(14) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7558
#    endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7559
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7560
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7561
    "unix default"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7562
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7563
    ^ 14
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7564
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7565
    "
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7566
     OperatingSystem maxFileNameLength
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7567
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7568
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7569
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7570
maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7571
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7572
%{
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7573
     long l;
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7574
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7575
     l = sysconf(_SC_OPEN_MAX);
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7576
     if (l >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7577
	 RETURN(__mkSmallInteger(l));
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7578
     }
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7579
%}.
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7580
     self primitiveFailed
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7581
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7582
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7583
      self maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7584
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7585
!
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7586
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7587
maxPathLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7588
    "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
  7589
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7590
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7591
    RETURN ( __MKSMALLINT(MAXPATHLEN) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7592
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7593
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7594
     OperatingSystem maxPathLength
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7595
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7596
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7597
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7598
pathSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7599
    "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
  7600
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7601
    ^ $:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7602
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7603
    "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
  7604
    "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
  7605
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7606
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7607
platformName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7608
    "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
  7609
     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
  7610
     #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
  7611
     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
  7612
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7613
    ^ #unix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7614
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7615
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7616
     OperatingSystem platformName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7617
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7618
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7619
    "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
  7620
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7621
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7622
primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7623
    "return the domain this host is in.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7624
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7625
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7626
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7627
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7628
#if defined(HAS_GETDOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7629
    char buffer[128];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7630
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7631
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7632
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7633
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7634
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7635
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7636
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7637
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7638
    if (uname(&ubuff) >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7639
	RETURN (__MKSTRING(ubuff.domainname));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7640
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7641
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7642
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7643
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7644
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7645
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7646
    if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7647
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7648
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7649
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7650
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7651
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7652
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7653
    ^ nil
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7654
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7655
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7656
     OperatingSystem primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7657
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7658
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7659
    "Modified: 26.4.1996 / 10:04:54 / stefan"
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7660
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7661
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7662
primGetHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7663
    "return the hostname we are running on - if there is
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7664
     a HOST environment variable, we are much faster here ...
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7665
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7666
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7667
6960
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7668
%{  /* STACK: 100000 */
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7669
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7670
    /* sigh - with libc.so.6, gethostname needs huge amounts of stack
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7671
     * actually this is linux specific, but should not hurt others
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7672
     */
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7673
#if defined(HAS_GETHOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7674
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7675
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7676
    if (gethostname(buffer, sizeof(buffer)) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7677
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7678
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7679
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7680
# if defined(HAS_UNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7681
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7682
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7683
    if (uname(&ubuff) >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7684
	RETURN (__MKSTRING(ubuff.nodename));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7685
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7686
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7687
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7688
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7689
    int ret;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7690
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7691
    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
  7692
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7693
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7694
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7695
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7696
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7697
%}.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7698
    ^ nil
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7699
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7700
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7701
     OperatingSystem getHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7702
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7703
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7704
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7705
setLocaleInfo:anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7706
    "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
  7707
     (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
  7708
     See description of fields in #getLocaleInfo.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7709
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7710
     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
  7711
     it should be used by applications as required."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7712
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7713
    LocaleInfo := anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7714
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7715
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7716
     |d|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7717
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7718
     d := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7719
     d at:#decimalPoint                 put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7720
     d at:#thousandsSeparator           put:','         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7721
     d at:#currencySymbol               put:'USD'       .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7722
     d at:#monetaryDecimalPoint         put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7723
     d at:#monetaryThousandsSeparator   put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7724
     d at:#fractionalDigits             put:2           .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7725
     d at:#positiveSign                 put:'+'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7726
     d at:#negativeSign                 put:'-'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7727
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7728
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7729
     OperatingSystem setLocaleInfo:d
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7730
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7731
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7732
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7733
supportsChildInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7734
    "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
  7735
     through interrupts (i.e. SIGCHILD)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7737
%{  /* NOCONTEXT */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  7738
#if defined(SIGCHLD) || defined(SIGCLD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7739
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7740
#endif
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
    ^ false
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
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7745
     OperatingSystem supportsChildInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7746
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7747
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7748
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7749
supportsIOInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7750
    "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
  7751
     (i.e. SIGPOLL/SIGIO).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7752
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7753
     Currently, this mechanism does not work on all
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7754
     systems ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7755
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7756
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7757
%{  /* NOCONTEXT */
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
  /* positive defines here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7760
   *  - irix5.2 does not work
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7761
   */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7762
#if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7763
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7764
# if defined(SIGIO) || defined(SIGPOLL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7765
#  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
  7766
#   if defined(F_SETOWN) || defined(FIOSETOWN)
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
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7770
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7771
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7772
# endif
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
#endif /* machines where it works */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7775
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7776
    ^ false
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
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7779
     OperatingSystem supportsIOInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7780
    "
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7781
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7782
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7783
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7784
supportsNonBlockingIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7785
    "return true, if the OS supports nonblocking IO."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7786
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7787
%{  /* NOCONTEXT */
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  7788
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  7789
# 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
  7790
       RETURN (true);
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  7791
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7792
#endif
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
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7795
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7796
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7797
     OperatingSystem supportsNonBlockingIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7798
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7799
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7800
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7801
supportsSelect
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7802
    "return true, if the OS supports selecting on multiple
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7803
     filedescriptors via select.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7804
     If false is returned, ProcessorScheduler will poll in 50ms
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7805
     intervals for I/O becoming ready."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7806
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7807
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7808
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7809
#if defined(sco)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7810
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7811
     * sco has a select, but its broken: always waiting 1 second
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7812
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7813
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7814
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7815
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7816
    ^ true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7817
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7818
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7819
     OperatingSystem supportsSelect
3496
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
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7822
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7823
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7824
supportsSymbolicLinks
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7825
    "return true, if the OS supports symbolic (soft) links;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7826
     most UNIX'es do; many other OS's do not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7827
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7828
%{  /* NOCONTEXT */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7829
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7830
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7831
    /*
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7832
     * assume yes - if that is defined.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7833
     */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7834
    RETURN(true);
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7835
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7836
%}.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7837
    ^ false
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7838
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7839
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7840
     OperatingSystem supportsSymbolicLinks
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7841
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7842
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7843
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7844
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7845
!UnixOperatingSystem class methodsFor:'path queries'!
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7846
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7847
defaultSystemPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7848
    "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
  7849
     (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
  7850
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
  7851
    |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
  7852
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7853
    majorVersionNr := Smalltalk majorVersionNr.
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7854
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7855
    sysPath := super defaultSystemPath.
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7856
    #(
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7857
	'/usr/local/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7858
	'/usr/local/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7859
	'/usr/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7860
	'/usr/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7861
	'/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7862
	'/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7863
	'/opt/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7864
	'/opt/smalltalk'
7698
d8cd175e8e29 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7681
diff changeset
  7865
    ) do:[:dirName |
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7866
	|dir|
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7867
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7868
	dir := dirName asFilename.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7869
	(dir isDirectory) ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7870
	    "/ try to guess a gnu-smalltalk; skip it
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7871
	    (dir construct:'initialize.st') exists ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7872
		releaseFile := dir construct:'RELEASE'.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7873
		releaseFile exists ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7874
		    s := releaseFile readStreamOrNil.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7875
		    s notNil ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7876
			v := Integer readFrom:s onError:-1.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7877
			s close.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7878
			v == majorVersionNr ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7879
			    sysPath add:dirName
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7880
			] ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7881
			    ('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE mismatch)') infoPrintCR.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7882
			]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7883
		    ] ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7884
			('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE missing)') infoPrintCR.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7885
		    ]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7886
		]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7887
	    ]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  7888
	]
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7889
    ].
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7890
    ^ sysPath
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7891
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7892
    "
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7893
     OperatingSystem defaultSystemPath
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7894
    "
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7895
! !
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7896
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7897
!UnixOperatingSystem class methodsFor:'private'!
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7898
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7899
mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7900
    "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
  7901
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7902
    |entries|
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7903
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7904
    entries := OrderedCollection new.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7905
    ('/proc/mounts' asFilename) readingLinesDo:[:eachLine |
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7906
	|items mountInfo|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7907
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7908
	items := eachLine asCollectionOfWords.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7909
	mountInfo := (MountInfo new
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7910
	    mountPointPath:(items at:2)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7911
	    deviceOrRemotePath:(items at:1)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7912
	    fsType:(items at:3)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7913
	    attributeString:(items at:4)).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7914
	entries add:mountInfo
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7915
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7916
    ^ entries
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7917
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7918
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7919
     OperatingSystem mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7920
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7921
!
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  7922
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7923
osProcessStatusClass
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7924
    ^ OSProcessStatus
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7925
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7926
    "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
  7927
! !
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7928
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7929
!UnixOperatingSystem class methodsFor:'shared memory access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7930
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7931
shmAttach:id address:addr flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7932
    "low level entry to shmat()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7933
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7934
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7935
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7936
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7937
    void *address, *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7938
    int shmflg, shmid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7939
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7940
    if (__isSmallInteger(addr)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7941
     && __bothSmallInteger(flags, id)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7942
	shmaddr = (void *) __intVal(addr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7943
	shmflg = __intVal(flags);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7944
	shmid = __intVal(id);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7945
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7946
	address = shmat(shmid, shmaddr, shmflg);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7947
	if (address != (void *)-1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7948
	    RETURN (__MKEXTERNALBYTES(addr));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7949
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7950
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7951
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7952
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7953
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7954
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7955
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7956
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7957
    "Modified: 22.4.1996 / 13:15:12 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7958
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7959
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7960
shmDetach:addr
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7961
    "low level entry to shmdt()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7962
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7963
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7964
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7965
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7966
    void *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7967
    int rslt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7968
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7969
    if (__isSmallInteger(addr)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7970
	shmaddr = (void *) __intVal(addr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7971
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7972
	rslt = shmdt(shmaddr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7973
	if (rslt != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7974
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7975
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7976
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7977
	RETURN (false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7978
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7979
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7980
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7981
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7982
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7983
    "Modified: 22.4.1996 / 13:15:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7984
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7985
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7986
shmGet:key size:size flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7987
    "low level entry to shmget()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7988
     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
  7989
     - use the provided wrapper class SharedExternalBytes instead."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7990
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7991
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7992
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7993
    if (__bothSmallInteger(key, size)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7994
     && __isSmallInteger(flags)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7995
	int rslt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7996
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7997
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7998
	if (rslt != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7999
	    RETURN (__MKSMALLINT(rslt));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8000
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8001
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8002
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8003
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8004
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8005
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8006
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8007
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8008
    "Modified: 22.4.1996 / 13:14:46 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8009
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8010
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8011
!UnixOperatingSystem class methodsFor:'socket creation'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8012
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8013
socketAccessor
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8014
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8015
    ^ SocketHandle
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8016
!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8017
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8018
socketWithDomain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8019
    "set up socket with domain, type and protocol number.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8020
     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
  8021
     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
  8022
     #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8023
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8024
    ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8025
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8026
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8027
!UnixOperatingSystem class methodsFor:'time and date'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8028
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8029
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
  8030
    "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
  8031
     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
  8032
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8033
    ^ self
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8034
	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
  8035
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8036
    "
5639
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  8037
     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
  8038
     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
  8039
     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
  8040
     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
  8041
    "
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8042
!
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8043
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8044
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
  8045
    "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
  8046
     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
  8047
     any daylight saving adjustings."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8048
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8049
    ^ self
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8050
	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
  8051
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8052
     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
  8053
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8054
!
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8055
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8056
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
  8057
    "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
  8058
     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
  8059
     otherwise, in localtime including any daylight saving adjustings."
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8060
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8061
    |osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8062
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
    struct tm tm;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8065
    TIME_T t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8066
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8067
    if (__bothSmallInteger(y, m)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8068
     && __bothSmallInteger(d, h)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8069
     && __bothSmallInteger(min, s)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8070
	tm.tm_hour = __intVal(h);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8071
	tm.tm_min = __intVal(min);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8072
	tm.tm_sec = __intVal(s);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8073
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8074
	tm.tm_year = __intVal(y) - 1900;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8075
	tm.tm_mon = __intVal(m) - 1;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8076
	tm.tm_mday = __intVal(d);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8077
	tm.tm_isdst = -1;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8078
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8079
	t = mktime(&tm);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8080
	if (utcBoolean == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8081
	    t += TIMEZONE(&tm);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8082
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8083
	osSeconds = __MKUINT((INT)t);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8084
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8085
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8086
    osSeconds notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8087
	^ osSeconds * 1000 + millis
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8088
    ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8089
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8090
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8091
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8092
     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
  8093
     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
  8094
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8095
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8096
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8097
getMicrosecondTime
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8098
    "This returns the microsecond timers value - if available.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8099
     On some machines, times with this precision may not be available,
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8100
     on those, the returned value may be rounded towards some internal
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8101
     clock resolution value."
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8102
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8103
    |seconds micros error|
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8104
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8105
%{
8618
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
  8106
#if defined(_POSIX_MONOTONIC_CLOCK) && !defined(NO_CLOCK_GETTIME)
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8107
    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
  8108
    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
  8109
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8110
    if (has_clock_gettime) {
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8111
        if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8112
            seconds = __MKUINT(ts.tv_sec);
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8113
            micros  = __MKUINT(ts.tv_nsec / 1000);
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8114
            goto out;
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8115
        } else {
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8116
            /* 
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8117
             * clock_gettime is not implemented in the kernel
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8118
             * fall through to alternative implementation
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8119
             */
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8120
            has_clock_gettime = 0;
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8121
        }
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8122
    }
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8123
#endif
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8124
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8125
#if defined(HAS_GETTIMEOFDAY)
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8126
    struct timeval tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8127
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8128
    gettimeofday(&tb, NULL /* &tzb */);
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8129
    if (tb.tv_usec >= (1000*1000)) {
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8130
        error = @symbol(bad);
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8131
    }
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8132
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8133
    seconds = __MKUINT(tb.tv_sec);
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8134
    micros  = __MKUINT(tb.tv_usec);
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8135
#endif
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8136
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8137
out:;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8138
%}.
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8139
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8140
    seconds notNil ifTrue:[
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8141
        ^ (seconds * 1000000) + micros
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8142
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8143
    error isNil ifTrue:[
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8144
        ^ self getMillisecondTime * 1000
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8145
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8146
    self primitiveFailed:error.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8147
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8148
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8149
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8150
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8151
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8152
!
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8153
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8154
getMillisecondTime
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8155
    "Return the millisecond timers value.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8156
     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
  8157
     LargeInteger arithmetic when doing timeouts and delays.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8158
     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
  8159
     short relative time deltas.
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8160
     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
  8161
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8162
     BAD DESIGN:
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8163
        This should be changed to return some instance of RelativeTime,
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8164
        and these computations moved there.
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8165
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8166
     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
  8167
     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
  8168
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8169
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8170
%{  /* NOCONTEXT */
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
    long t = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8173
8618
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
  8174
#if defined(_POSIX_MONOTONIC_CLOCK) && !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
  8175
    static has_clock_gettime = 1;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8176
    struct timespec ts;
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8177
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8178
    if (has_clock_gettime) {
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8179
        if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8180
            t = ts.tv_sec*1000 + ts.tv_nsec/1000000;
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8181
            goto out;
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8182
        } else {
8601
bf2b973a9a0e unimpl clock-syscall handling
Claus Gittinger <cg@exept.de>
parents: 8599
diff changeset
  8183
            /* 
bf2b973a9a0e unimpl clock-syscall handling
Claus Gittinger <cg@exept.de>
parents: 8599
diff changeset
  8184
             * clock_gettime is not implemented in the kernel
bf2b973a9a0e unimpl clock-syscall handling
Claus Gittinger <cg@exept.de>
parents: 8599
diff changeset
  8185
             * fall through to alternative implementation
bf2b973a9a0e unimpl clock-syscall handling
Claus Gittinger <cg@exept.de>
parents: 8599
diff changeset
  8186
             */
bf2b973a9a0e unimpl clock-syscall handling
Claus Gittinger <cg@exept.de>
parents: 8599
diff changeset
  8187
            has_clock_gettime = 0;
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8188
        }
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8189
    }
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8190
#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
  8191
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8192
#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
  8193
/*
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8194
 * 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
  8195
 * 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
  8196
 */
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8197
# include <sys/times.h>
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8198
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8199
    static int millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8200
    clock_t ticks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8201
    struct tms tb;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8202
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8203
    if (!millisecondsPerTick) {
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8204
        int ticksPerSecond = sysconf(_SC_CLK_TCK);
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8205
        if (ticksPerSecond <= 0)
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8206
            goto err;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8207
        if (ticksPerSecond > 1000)
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8208
            goto err;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8209
        millisecondsPerTick = 1000 / ticksPerSecond;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8210
/*
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8211
printf("milliSecondsPerTick: %d\n", millisecondsPerTick);
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8212
*/
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8213
    }
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8214
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8215
    ticks = times(&tb);
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8216
    if (ticks < 0)
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8217
        goto err;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8218
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8219
    t = ticks * millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8220
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8221
#else /* !times */
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8222
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8223
    /* assume HAS_GETTIMEOFDAY
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8224
     * - will result in a linkage error
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8225
     * if not fixed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8226
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8227
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8228
    struct timeval tb;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8229
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8230
    gettimeofday(&tb, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8231
    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
  8232
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8233
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8234
out:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8235
    RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) );
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8236
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8237
err:;
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8238
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8239
    self primitiveFailed
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8240
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8241
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8242
    "
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8243
      self getMillisecondTime
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8244
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8245
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8246
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8247
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8248
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8249
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8250
getOSTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8251
    "This returns the OS time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8252
     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
  8253
     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
  8254
     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
  8255
     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
  8256
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8257
     Dont use this method in application code since it is an internal (private)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8258
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  8259
     or use instances of Time, Date or Timestamp to work with.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8260
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8261
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8262
    |time seconds millis|
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8263
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8264
    time := self primGetOSTime.
7738
d08da93d4a5f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7736
diff changeset
  8265
    time class == Array ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8266
	seconds := time at:1.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8267
	millis := time at:2.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8268
	time := (seconds * 1000) + millis
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8269
    ].
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8270
    ^ time
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8271
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8272
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8273
     OperatingSystem getOSTime printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8274
     Delay waitForSeconds:0.2.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8275
     OperatingSystem getOSTime printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8276
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8277
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8278
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8279
primGetOSTime
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8280
    "This returns the OS time.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8281
     The base of the returned value is not consistent across
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8282
     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
  8283
     others since 1900. The Time classes are prepared for this, and
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8284
     converts as appropriate (by using my fromOSTime: conversion methods).
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8285
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8286
     Dont use this method in application code since it is an internal (private)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8287
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  8288
     or use instances of Time, Date or Timestamp to work with.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8289
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8290
7741
0bbe687607e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7739
diff changeset
  8291
%{  /* NOCONTEXT */
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8292
    long t;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8293
    long _secs, _millis;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8294
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8295
#if !defined(HAS_GETTIMEOFDAY)
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8296
# if defined(HAS_FTIME)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8297
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8298
	struct timeb timebuffer;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8299
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8300
	ftime(&timebuffer);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8301
	_secs = timebuffer.time;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8302
	_millis = timebuffer.millitm;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8303
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8304
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8305
# endif /* HAS_FTIME */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8306
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8307
# ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8308
#  if defined(SYSV) && defined(HZ)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8309
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8310
	/*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8311
	 * sys5 time; we have to fake the information
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8312
	 * the returned value is inexact.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8313
	 */
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8314
	long ticks;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8315
	struct tms tb;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8316
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8317
	_secs = time(0);   /* seconds since 1970 ... */
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8318
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8319
	ticks = times(&tb);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8320
	t = (ticks * 1000) / HZ;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8321
	t = t % 1000;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8322
	_millis = __MKSMALLINT(t);
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8323
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8324
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8325
#  endif /* OLD SYSV stuff */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8326
# endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8327
#endif /* no HAS_GETTIMEOFDAY */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8328
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8329
#ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8330
    /*
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8331
     * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8332
     * 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
  8333
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8334
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8335
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8336
	/*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8337
	 * bsd time
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8338
	 */
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8339
	struct timeval tb;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8340
	/* struct timezone tzb; */
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8341
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8342
	gettimeofday(&tb, NULL /* &tzb */);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8343
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8344
	_secs = tb.tv_sec;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8345
	_millis = tb.tv_usec / 1000;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8346
    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8347
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8348
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8349
    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8350
     * mhmh long-long stuff seems not to work correctly
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8351
     * on all machines (sparc)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8352
     * being conservative here ...
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8353
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8354
7766
0acb8e2cfe50 Fix syntax error on sparc
Stefan Vogel <sv@exept.de>
parents: 7762
diff changeset
  8355
#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(i386)
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8356
# define HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8357
#endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8358
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8359
#ifdef alpha64
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8360
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8361
	unsigned INT _lsecs, _lmillis, rslt;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8362
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8363
	_lsecs = (INT)_secs;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8364
	_lmillis = (INT)_millis;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8365
	rslt = _lsecs * 1000 + _lmillis;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8366
	RETURN (__MKUINT(rslt));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8367
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8368
#else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8369
# ifdef HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8370
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8371
	unsigned long long _lsecs, _lmillis, rslt;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8372
	unsigned low, hi;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8373
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8374
	_lsecs = (long long)_secs;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8375
	_lmillis = (long long)_millis;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8376
	rslt = _lsecs * 1000 + _lmillis;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8377
	low = rslt & 0xFFFFFFFF;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8378
	hi = rslt >> 32;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8379
	RETURN (__MKLARGEINT64(1, low, hi));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8380
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8381
# else
7741
0bbe687607e0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7739
diff changeset
  8382
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8383
	OBJ seconds, millis, rslt;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8384
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8385
	seconds = __MKUINT(_secs);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8386
	__PROTECT__(seconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8387
	millis = __MKUINT(_millis);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8388
	__PROTECT__(millis);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8389
	rslt = __ARRAY_WITH2(seconds, millis);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8390
	__UNPROTECT__(millis);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8391
	__UNPROTECT__(seconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8392
	RETURN ( rslt );
7766
0acb8e2cfe50 Fix syntax error on sparc
Stefan Vogel <sv@exept.de>
parents: 7762
diff changeset
  8393
    }
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8394
# endif /* long long */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8395
#endif /* alpha64 */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8396
%}.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8397
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8398
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8399
     OperatingSystem primGetOSTime printCR.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8400
     Delay waitForSeconds:0.2.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8401
     OperatingSystem primGetOSTime printCR.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8402
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8403
!
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8404
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8405
sleep:numberOfSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8406
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8407
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8408
    "cease ANY action for some time. This suspends the whole smalltalk
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8409
     (unix-) process for some time if running threadless;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8410
     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
  8411
     only block until the next clock tick and return with the next
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8412
     timer interrupt.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8413
     Use either OperatingSystem>>millisecondDelay: (which makes all
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8414
     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
  8415
     only the calling thread sleep)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8416
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8417
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8418
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8419
    if (__isSmallInteger(numberOfSeconds)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8420
	sleep(__intVal(numberOfSeconds));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8421
	RETURN ( self );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8422
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8423
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8424
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8425
     argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8426
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8427
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8428
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8429
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8430
     OperatingSystem sleep:2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8431
    "
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8432
!
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8433
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8434
timeInfoFromSeconds:osSeconds milliseconds:osMilliseconds localTime:isLocalTime
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8435
    "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
  8436
     OS-second value.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8437
     An internal helper"
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8438
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8439
    |year month day hours minutes seconds utcOffset
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8440
     dst yDay wDay info|
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8441
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8442
%{
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8443
    struct tm *tmPtr;
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8444
    INT t;
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8445
    TIME_T tt;
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8446
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8447
    t = __longIntVal(osSeconds);
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8448
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8449
    /* try cache */
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8450
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8451
	OBJ lastSeconds, lastTimeInfo;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8452
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8453
	lastSeconds = @global(LastTimeInfoSeconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8454
	if (lastSeconds
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8455
	 && (__longIntVal(lastSeconds) == t)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8456
	 && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8457
	 && (@global(LastTimeInfoIsLocal) == isLocalTime)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8458
	) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8459
	    lastTimeInfo = @global(LastTimeInfo);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8460
	    if (lastTimeInfo != nil) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8461
		RETURN (lastTimeInfo);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8462
	    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8463
	}
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8464
    }
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8465
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8466
    tt = (TIME_T)t;
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8467
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8468
    if (isLocalTime == true) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8469
	tmPtr = localtime(&tt);
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8470
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8471
	tmPtr = gmtime(&tt);
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8472
    }
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8473
    hours = __MKSMALLINT(tmPtr->tm_hour);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8474
    minutes = __MKSMALLINT(tmPtr->tm_min);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8475
    seconds = __MKSMALLINT(tmPtr->tm_sec);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8476
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8477
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8478
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8479
    day = __MKSMALLINT(tmPtr->tm_mday);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8480
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8481
    yDay = __MKSMALLINT(tmPtr->tm_yday+1);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8482
    wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8483
    utcOffset = __MKSMALLINT(TIMEZONE(tmPtr));
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8484
    dst = (tmPtr->tm_isdst == 0 ? false : true);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8485
%}.
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8486
    info := self timeInfoClass new.
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8487
    info
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8488
	year:year
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8489
	month:month
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8490
	day:day
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8491
	hours:hours
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8492
	minutes:minutes
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8493
	seconds:seconds
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8494
	milliseconds:osMilliseconds
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8495
	utcOffset:utcOffset
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8496
	dst:dst
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8497
	dayInYear:yDay
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8498
	dayInWeek:wDay.
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8499
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8500
%{
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8501
    @global(LastTimeInfo) = info;                       __GSTORE(info);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8502
    @global(LastTimeInfoSeconds) = osSeconds;           __GSTORE(osSeconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8503
    @global(LastTimeInfoMilliseconds) = osMilliseconds; __GSTORE(osMilliseconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8504
    @global(LastTimeInfoIsLocal) = isLocalTime;         __GSTORE(isLocalTime);
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8505
%}.
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8506
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8507
    ^ info
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8508
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8509
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8510
     OperatingSystem timeInfoFromSeconds:0 localTime:false
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8511
     OperatingSystem timeInfoFromSeconds:3600 localTime:false
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8512
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8513
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8514
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8515
!UnixOperatingSystem class methodsFor:'users & groups'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8516
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8517
getEffectiveGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8518
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8519
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8520
    "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
  8521
     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
  8522
     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
  8523
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8524
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8525
    int uid;
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
    uid = getegid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8528
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8529
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8530
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8531
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8532
     OperatingSystem getEffectiveGroupID
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8536
getEffectiveUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8537
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8538
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8539
    "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
  8540
     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
  8541
     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
  8542
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8543
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8544
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8545
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8546
    uid = geteuid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8547
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8548
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8549
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8550
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8551
     OperatingSystem getEffectiveUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8552
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8553
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8554
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8555
getFullUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8556
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8557
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8558
    "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
  8559
     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
  8560
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8561
    |info gecos|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8562
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8563
    info := self userInfoOf:userID.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8564
    (info notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8565
    and:[info includesKey:#gecos]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8566
	gecos := info at:#gecos.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8567
	(gecos includes:$,) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8568
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8569
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8570
	^ gecos
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8571
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8572
    ^ self getUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8573
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8574
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8575
     OperatingSystem getFullUserNameFromID:0
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8576
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8577
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8578
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8579
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8580
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8581
    "Modified: 15.7.1996 / 12:44:21 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8582
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8583
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8584
getGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8585
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8587
    "return the current users (thats you) numeric group id"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8588
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8589
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8590
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8591
    int uid;
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
    uid = getgid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8594
    RETURN ( __MKSMALLINT(uid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8595
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8596
    ^ 1 "just a dummy for systems which do not have userIDs"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8597
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8598
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8599
     OperatingSystem getGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8600
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8601
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8602
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8603
getGroupNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8604
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8605
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8606
    "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
  8607
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8608
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8609
    struct group *g;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8610
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8611
    if (__isSmallInteger(aNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8612
	g = getgrgid(__intVal(aNumber));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8613
	if (g) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8614
	    RETURN ( __MKSTRING(g->gr_name) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8615
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8616
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8617
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8618
    ^ '???'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8619
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8620
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8621
     OperatingSystem getGroupNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8622
     OperatingSystem getGroupNameFromID:10
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8623
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8624
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8625
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8626
getHomeDirectory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8627
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8628
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8629
    "return the name of the users home directory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8630
     (i.e. yours)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8631
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8632
    ^ UnixOperatingSystem getEnvironment:'HOME'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8633
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8634
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8635
     OperatingSystem getHomeDirectory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8636
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8637
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8638
    "Modified: 24.1.1997 / 11:32:13 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8639
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8640
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8641
getLoginName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8642
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8643
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8644
    "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
  8645
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8646
%{  /* NOCONTEXT */
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  8647
    static char cachedName[128];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8648
    static firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8649
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8650
    extern char *getlogin();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8651
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8652
    char *name = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8653
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8654
    if (firstCall) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8655
	/*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8656
	 * try a few common environment variables ...
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8657
	 */
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8658
	name = getenv("LOGNAME");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8659
	if (! name || (name[0] == 0)) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8660
	    name = getlogin();
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8661
	    if (! name || (name[0] == 0) ) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8662
		name = getenv("LOGIN");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8663
		if (! name || (name[0] == 0) ) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8664
		    name = getenv("USER");
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
	    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8667
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8668
	if (name && (strlen(name) < sizeof(cachedName))) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8669
	    strcpy(cachedName, name);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8670
	    firstCall = 0;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8671
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8672
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8673
	name = cachedName;
7767
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
  8674
    }
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
  8675
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8676
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8677
     * nope - I really font know who you are.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8678
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8679
    if (! name || (name[0] == 0) ) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8680
	name = "you";
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8681
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8682
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8683
    RETURN ( __MKSTRING(name) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8684
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8685
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8686
     OperatingSystem getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8687
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8688
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8689
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8690
getUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8691
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8692
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8693
    "return the current users (thats you) numeric user id"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8694
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8695
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8696
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8697
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8698
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8699
    uid = getuid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8700
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8701
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8702
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8703
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8704
     OperatingSystem getUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8705
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8706
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8707
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8708
getUserNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8709
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8710
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8711
    "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
  8712
     This is the login name, not the fullName."
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8715
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8716
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8717
    struct passwd *p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8718
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8719
    if (__isSmallInteger(aNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8720
	p = getpwuid(__intVal(aNumber));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8721
	if (p) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8722
	    RETURN ( __MKSTRING(p->pw_name) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8723
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8724
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8725
#endif /* unix-like */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8726
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8727
    aNumber == self getUserID ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8728
	^ self getLoginName
3496
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
    ^ '? (' , aNumber printString , ')'
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8734
     OperatingSystem getUserNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8735
     OperatingSystem getUserNameFromID:100
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8736
     OperatingSystem getUserNameFromID:9991
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8737
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8738
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8739
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8740
userInfoOf:aNameOrID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8741
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8742
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8743
    "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
  8744
     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
  8745
     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
  8746
     DOS systems return nothing;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8747
     non-SYSV4 systems have no age/comment.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8748
     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
  8749
     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
  8750
     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
  8751
     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
  8752
     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
  8753
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8754
    |info name passw uid gid age comment
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8755
     gecos dir shell|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8756
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8757
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8758
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8759
    struct passwd *buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8760
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8761
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8762
    if (__isStringLike(aNameOrID)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8763
	buf = getpwnam(__stringVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8764
    } else if (__isSmallInteger(aNameOrID)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8765
	buf = getpwuid(__intVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8766
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8767
	buf = (struct passwd *)0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8768
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8769
    if (buf) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8770
	name = __MKSTRING(buf->pw_name);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8771
#  ifndef NO_PWD_PASSWD
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8772
	passw = __MKSTRING(buf->pw_passwd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8773
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8774
#  ifdef SYSV4
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8775
	age = __MKSTRING(buf->pw_age);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8776
	comment = __MKSTRING(buf->pw_comment);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8777
#  endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8778
	dir = __MKSTRING(buf->pw_dir);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8779
#  ifndef NO_PWD_GECOS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8780
	gecos = __MKSTRING(buf->pw_gecos);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8781
#  endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8782
	shell = __MKSTRING(buf->pw_shell);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8783
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8784
	uid = __MKSMALLINT(buf->pw_uid);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8785
	gid = __MKSMALLINT(buf->pw_gid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8786
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8787
# endif /* has PWD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8788
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8789
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8790
    name isNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8791
	aNameOrID == self getUserID ifTrue:[
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8792
	    name := self getLoginName
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8793
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8794
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8795
    name notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8796
	info at:#name put:name.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8797
    ] ifFalse:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8798
	info at:#name put:'unknown'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8799
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8800
    passw notNil ifTrue:[info at:#passwd put:passw].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8801
    age notNil ifTrue:[info at:#age put:age].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8802
    comment notNil ifTrue:[info at:#comment put:comment].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8803
    gecos notNil ifTrue:[info at:#gecos put:gecos].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8804
    shell notNil ifTrue:[info at:#shell put:shell].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8805
    dir isNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8806
	aNameOrID == self getUserID ifTrue:[
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8807
	    dir := self getHomeDirectory
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8808
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8809
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8810
    dir notNil ifTrue:[info at:#dir put:dir].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8811
    uid notNil ifTrue:[info at:#uid put:uid].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8812
    gid  notNil ifTrue:[info at:#gid put:gid].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8813
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8814
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8815
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8816
     OperatingSystem userInfoOf:'root'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8817
     OperatingSystem userInfoOf:1
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8818
     OperatingSystem userInfoOf:'claus'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8819
     OperatingSystem userInfoOf:'fooBar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8820
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8821
    "
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8824
!UnixOperatingSystem class methodsFor:'waiting for events'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8825
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8826
blockingChildProcessWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8827
     "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
  8828
      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
  8829
      a subprocesses status (to avoid blocking)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8830
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8831
%{ /*NOCONTEXT*/
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  8832
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8833
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8834
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8835
    RETURN(true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8836
#endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8840
childProcessWait:blocking pid:pidToWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8841
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8842
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8843
    "get status changes from child processes.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8844
     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
  8845
     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
  8846
     otherwise we return immediately.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8847
     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
  8848
     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
  8849
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8850
    |pid status code core|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8851
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8852
    int p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8853
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8854
#if defined(HAS_WAITPID)
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
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8857
#   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
  8858
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8859
#else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8860
# if defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8861
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8862
    union wait s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8863
#   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
  8864
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8865
# 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
  8866
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8867
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8868
#   define __WAIT      wait(&s)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8869
#   define __BLOCKING_WAIT__ 1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8870
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8871
    if (blocking != true) {
6992
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
	 * We do not support nonBlocking waits, so signal an error
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8874
	 * Sorry about the goto, but with all these ifdefs ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8875
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8876
	goto done;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8877
    }
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8878
# endif /*!HAS_WAIT3*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8879
#endif  /*!HAS_WAITPID*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8880
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8881
#if !defined(WIFEXITED)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8882
# define WIFEXITED(stat)      (((int)((stat)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8883
# 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
  8884
# 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
  8885
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8886
# define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8887
# define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8888
# define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8889
#endif /*!WIFEXITED*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8890
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8891
#if !defined(WCOREDUMP)
3496
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
    * 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
  8894
    */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8895
# if defined(HAS_WAIT3)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8896
#  define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8897
# else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8898
#  define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8899
# endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8900
#endif /*!WCOREDUMP*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8901
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8902
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8903
    __BEGIN_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8904
#endif
3496
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
    do {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8907
	p = __WAIT;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8908
    } while (p == -1 && errno == EINTR);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8909
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8910
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8911
    __END_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8912
#  undef __BLOCKING_WAIT__
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8913
#endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8914
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8915
#undef __WAIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8916
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8917
    if (p == 0)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8918
	RETURN(nil)
3496
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
    if (p == -1) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8921
	if (errno == ECHILD)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8922
	    RETURN(nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8923
    } else {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8924
	pid = __MKSMALLINT(p);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8925
	if (WIFEXITED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8926
	    status = @symbol(exit);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8927
	    code = __MKSMALLINT(WEXITSTATUS(s));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8928
	    core = WCOREDUMP(s) ? true : false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8929
	} else if (WIFSIGNALED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8930
	    status = @symbol(signal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8931
	    code = __MKSMALLINT(WTERMSIG(s));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8932
	} else if (WIFSTOPPED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8933
	    status = @symbol(stop);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8934
	    code = __MKSMALLINT(WSTOPSIG(s));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8935
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8936
#if defined(WIFCONTINUED)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8937
	else if (WIFCONTINUED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8938
	    status = @symbol(continue);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8939
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8940
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8941
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8942
done: ;
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8945
    (status isNil or:[pid isNil]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8946
	^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8947
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8948
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8949
"/ 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
  8950
"/ show:' code: '; show:code; show:' core:'; showCR:core.
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
    ^ 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
  8953
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8954
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8955
     OperatingSystem childProcessWait:false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8956
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8957
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8958
    "Created: 5.1.1996 / 16:39:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8959
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8960
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8961
isBlockingOn:fd
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8962
    "{ Pragma: +optSpace }"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8963
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8964
    "return the blocking attribute - if set (which is the default)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8965
     a read on the fileDescriptor will block until data is available.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8966
     If clear, a read operation will immediately return with a value nil.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8967
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8968
     blocking is off"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8969
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8970
%{  /* NOCONTEXT */
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8971
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8972
    int flags;
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8973
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8974
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8975
# undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8976
# if defined(O_NONBLOCK)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8977
#  define DELAY_FLAG O_NONBLOCK
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8978
# elif defined(O_NDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8979
#  define DELAY_FLAG O_NDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8980
# elif defined(FNDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8981
#  define DELAY_FLAG FNDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8982
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8983
# if defined(DELAY_FLAG)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8984
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8985
	int f = __intVal(fd);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8986
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8987
	flags = fcntl(f, F_GETFL, 0);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8988
	RETURN ((flags & DELAY_FLAG) ? false : true );
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8989
    }
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8990
#  undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8991
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8992
#endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8993
%}.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8994
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8995
     fd argument not integer or bad return code
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8996
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8997
    ^ self primitiveFailed
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8998
!
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8999
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9000
numAvailableForReadOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9001
    "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
  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
     * 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
  9006
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9007
# if 0 && defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9008
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9009
	int n;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9010
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9011
	if (__isSmallInteger(fd)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9012
	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9013
		RETURN (__MKINT(n));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9014
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9015
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9016
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9017
# endif /* FIONREAD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9018
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9019
    ^ (self readCheck:fd) ifTrue:[1] ifFalse:[0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9020
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9021
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9022
readCheck:fd
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9023
    "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
  9024
     (i.e. read is possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9025
     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
  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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9029
     * 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
  9030
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9031
#if 0 && defined(FIONREAD)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9032
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9033
	int result = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9034
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9035
	if (ioctl(__smallIntegerVal(fd), FIONREAD, &result) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9036
	    RETURN(result > 0 ? true : false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9037
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9038
    }
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9039
#endif /* FIONREAD */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9040
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9041
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9042
    ^ super readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9043
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9044
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9045
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9046
	readableInto:readableResultFdArray writableInto:writableResultFdArray
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9047
	exceptionInto:exceptionResultFdArray
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9048
	withTimeOut:millis
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9049
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9050
    "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
  9051
     writeFdArray to become ready for writing,
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9052
     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
  9053
     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
  9054
     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
  9055
     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
  9056
     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
  9057
     writableResultFdArray and exceptionResultFdArray respectively.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9058
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9059
     Return the (overall) number of selected filedescriptors.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9060
     readableResultFdArray, writableResultFdArray and exceptionResultFdArray will
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9061
     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
  9062
     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
  9063
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9064
%{
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9065
    fd_set rset, wset, eset;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9066
    struct timeval wt, et;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9067
    int maxF;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9068
    INT t;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9069
    int ret;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9070
    int cntR = 0, cntW = 0, cntE = 0;
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9071
    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
  9072
    int numFds = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9073
#ifndef __isArrayLike
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9074
# define __isArrayLike __isArray
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9075
#endif
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9076
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9077
    if (!__isSmallInteger(millis)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9078
	goto fail;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9079
    }
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9080
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9081
    if (readableResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9082
	if (! __isArrayLike(readableResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9083
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9084
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9085
	resultSizeReadable = __arraySize(readableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9086
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9087
    if (writableResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9088
	if (! __isArrayLike(writableResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9089
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9090
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9091
	resultSizeWritable = __arraySize(writableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9092
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9093
    if (exceptionResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9094
	if (! __isArrayLike(exceptionResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9095
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9096
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9097
	resultSizeException = __arraySize(exceptionResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9098
    }
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9099
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9100
    FD_ZERO(&rset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9101
    FD_ZERO(&wset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9102
    FD_ZERO(&eset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9103
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9104
    maxF = -1;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9105
    if (__isNonNilObject(readFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9106
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9107
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9108
	if (! __isArrayLike(readFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9109
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9110
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9111
	count = __arraySize(readFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9112
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9113
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9114
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9115
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9116
	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9117
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9118
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9119
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9120
			fprintf(stderr, "[OS] warning: funny read-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9121
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9122
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9123
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9124
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9125
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9126
		    if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9127
			FD_SET(f, &rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9128
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9129
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9130
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9131
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9132
			    fprintf(stderr, "[OS] warning: huge read-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9133
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9134
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9135
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9136
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9137
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9138
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9139
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9140
    if (__isNonNilObject(writeFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9141
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9142
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9143
	if (! __isArrayLike(writeFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9144
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9145
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9146
	count = __arraySize(writeFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9147
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9148
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9149
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9150
	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9151
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9152
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9153
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9154
			fprintf(stderr, "[OS] warning: funny write-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9155
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9156
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9157
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9158
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9159
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9160
		    if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9161
			FD_SET(f, &wset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9162
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9163
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9164
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9165
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9166
			    fprintf(stderr, "[OS] warning: huge write-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9167
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9168
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9169
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9170
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9171
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9172
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9173
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9174
    if (__isNonNilObject(exceptFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9175
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9176
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9177
	if (! __isArrayLike(exceptFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9178
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9179
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9180
	count = __arraySize(exceptFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9181
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9182
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9183
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9184
	    fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9185
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9186
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9187
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9188
			fprintf(stderr, "[OS] warning: funny except-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9189
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9190
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9191
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9192
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9193
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9194
		    if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9195
			FD_SET(f, &eset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9196
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9197
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9198
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9199
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9200
			    fprintf(stderr, "[OS] warning: huge except-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9201
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9202
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9203
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9204
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9205
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9206
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9207
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9208
    t = __intVal(millis);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9209
    if (t) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9210
	wt.tv_sec = t / 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9211
	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
  9212
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9213
	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
  9214
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9215
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9216
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9217
     * 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
  9218
     * 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
  9219
     */
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9220
    __BEGIN_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9221
    errno = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9222
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9223
    if (t == 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9224
	/*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9225
	 * if there is no timeout time, we can stay here interruptable.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9226
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9227
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9228
	    ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9229
	} 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
  9230
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9231
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9232
	    ret = select(maxF+1, &rset, &wset, &eset, &wt);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9233
	    /*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9234
	     * 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
  9235
	     * could otherwise stay in this loop forever ...
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9236
	     * 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
  9237
	     * 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
  9238
	     */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9239
	} 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
  9240
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9241
    __END_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9242
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9243
    if (ret > 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9244
	OBJ *__resultR = __arrayVal(readableResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9245
	OBJ *__resultW = __arrayVal(writableResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9246
	OBJ *__resultE = __arrayVal(exceptionResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9247
	int i;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9248
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9249
	for (i=0; i <= maxF; i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9250
	    if (FD_ISSET(i, &rset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9251
		if (cntR < resultSizeReadable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9252
		    __resultR[cntR] = __MKSMALLINT(i);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9253
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9254
		cntR++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9255
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9256
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9257
	    if (FD_ISSET(i, &wset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9258
		if (cntW < resultSizeWritable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9259
		    __resultW[cntW] = __MKSMALLINT(i);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9260
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9261
		cntW++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9262
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9263
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9264
	    if (FD_ISSET(i, &eset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9265
		if (cntE < resultSizeException) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9266
		    __resultE[cntE] = __MKSMALLINT(i);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9267
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9268
		cntE++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9269
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9270
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9271
	/* add a delimiter */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9272
	if (cntR < resultSizeReadable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9273
	    __resultR[cntR] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9274
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9275
	if (cntW < resultSizeWritable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9276
	    __resultW[cntW] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9277
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9278
	if (cntE < resultSizeException) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9279
	    __resultE[cntE] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9280
	}
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9281
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9282
	RETURN (__MKSMALLINT(cntR+cntW+cntE));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9283
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9284
	if (ret < 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9285
	    if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9286
		errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9287
		@global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9288
	    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9289
		if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9290
		    fprintf(stderr, "OS [info]: select errno = %d\n", errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9291
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9292
		@global(LastErrorNumber) = __MKSMALLINT(errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9293
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9294
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9295
	    @global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9296
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9297
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9298
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9299
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9300
     * Return 0 (no filedescriptor ready)
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9301
     */
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9302
    RETURN (__MKSMALLINT(0));
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9303
fail: ;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9304
%}.
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9305
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9306
     timeout argument not integer,
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9307
     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
  9308
     or not supported by OS
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9309
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9310
    ^ self primitiveFailed
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9311
!
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9312
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9313
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9314
    "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
  9315
     writeFdArray to become ready for writing,
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9316
     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
  9317
     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
  9318
     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
  9319
     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
  9320
     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
  9321
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9322
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9323
    fd_set rset, wset, eset;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9324
    struct timeval wt, et;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9325
    int f, maxF, i, lX, bX;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9326
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9327
    OBJ fd, retFd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9328
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9329
    int count;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9330
    int numFds = 0;
3801
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9331
#ifndef __isArrayLike
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9332
# define __isArrayLike __isArray
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9333
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9334
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9335
    if (__isSmallInteger(millis)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9336
	FD_ZERO(&rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9337
	FD_ZERO(&wset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9338
	FD_ZERO(&eset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9339
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9340
	maxF = -1;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9341
	if (__isNonNilObject(readFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9342
	    if (! __isArrayLike(readFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9343
		goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9344
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9345
	    count = __arraySize(readFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9346
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9347
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9348
		fd = __ArrayInstPtr(readFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9349
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9350
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9351
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9352
			    fprintf(stderr, "[OS] warning: funny read-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9353
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9354
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9355
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9356
			if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9357
			    FD_SET(f, &rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9358
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9359
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9360
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9361
			    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9362
				fprintf(stderr, "[OS] warning: huge read-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9363
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9364
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9365
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9366
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9367
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9368
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9369
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9370
	if (__isNonNilObject(writeFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9371
	    if (! __isArrayLike(writeFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9372
		goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9373
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9374
	    count = __arraySize(writeFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9375
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9376
		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9377
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9378
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9379
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9380
			    fprintf(stderr, "[OS] warning: funny write-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9381
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9382
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9383
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9384
			if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9385
			    FD_SET(f, &wset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9386
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9387
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9388
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9389
			    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9390
				fprintf(stderr, "[OS] warning: huge write-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9391
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9392
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9393
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9394
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9395
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9396
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9397
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9398
	if (__isNonNilObject(exceptFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9399
	    if (! __isArrayLike(exceptFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9400
		goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9401
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9402
	    count = __arraySize(exceptFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9403
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9404
		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9405
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9406
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9407
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9408
			    fprintf(stderr, "[OS] warning: funny except-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9409
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9410
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9411
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9412
			if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9413
			    FD_SET(f, &eset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9414
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9415
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9416
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9417
			    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9418
				fprintf(stderr, "[OS] warning: huge except-fd (0x%x) given to select\n", fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9419
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9420
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9421
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9422
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9423
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9424
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9425
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9426
	t = __intVal(millis);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9427
	if (t) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9428
	    wt.tv_sec = t / 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9429
	    wt.tv_usec = (t % 1000) * 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9430
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9431
	    wt.tv_sec = wt.tv_usec = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9432
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9433
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9434
	/*
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9435
	 * make certain, that interrupt gets us out of the select
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9436
	 * However, we must then care for moved objects.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9437
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9438
	__BEGIN_INTERRUPTABLE__
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9439
	errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9440
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9441
	if (t == 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9442
	    /*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9443
	     * if there is no timeout time, we can stay here interruptable.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9444
	     */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9445
	    do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9446
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9447
	    } while ((ret < 0) && (errno == EINTR));
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9448
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9449
	    do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9450
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9451
		/*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9452
		 * 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
  9453
		 * could otherwise stay in this loop forever ...
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9454
		 * 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
  9455
		 * 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
  9456
		 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9457
	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9458
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9459
	__END_INTERRUPTABLE__
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9460
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9461
	if (ret > 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9462
	    for (i=0; i <= maxF; i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9463
		if (FD_ISSET(i, &rset)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9464
		 || FD_ISSET(i, &wset)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9465
		 || FD_ISSET(i, &eset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9466
		    RETURN ( __MKSMALLINT(i) );
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9467
		}
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
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9470
	    if (ret < 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9471
		if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9472
		    errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9473
		    @global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9474
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9475
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9476
			fprintf(stderr, "OS [info]: select errno = %d\n", errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9477
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9478
		    @global(LastErrorNumber) = __MKSMALLINT(errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9479
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9480
	    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9481
		@global(LastErrorNumber) = nil;
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
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9484
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
	 * Return nil (means time expired or interrupted)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9487
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9488
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9489
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9490
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9491
fail: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9492
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9493
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9494
     timeout argument not integer,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9495
     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
  9496
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9497
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9498
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9499
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9500
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9501
setBlocking:aBoolean on:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9502
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9503
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9504
    "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
  9505
     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
  9506
     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
  9507
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9508
     blocking is off.
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9509
     Return the previous blocking state."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9510
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9511
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9512
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9513
    int ret = 0, flags;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9514
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9515
#if defined(F_GETFL) && defined(F_SETFL)
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9516
# undef DELAY_FLAG
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9517
# if defined(O_NONBLOCK)
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9518
#  define DELAY_FLAG O_NONBLOCK
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9519
# elif defined(O_NDELAY)
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9520
#  define DELAY_FLAG O_NDELAY
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9521
# elif defined(FNDELAY)
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9522
#  define DELAY_FLAG FNDELAY
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9523
# endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9524
# if defined(DELAY_FLAG)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9525
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9526
	int f = __intVal(fd);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9527
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9528
	flags = fcntl(f, F_GETFL, 0);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9529
	if (aBoolean == true) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9530
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9531
	} else if (aBoolean == false) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9532
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9533
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9534
	if (ret >= 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9535
	    RETURN ((flags & DELAY_FLAG) ? false : true );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9536
	}
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9537
    }
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9538
#  undef DELAY_FLAG
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9539
# endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9540
#endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9541
%}.
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9542
    "
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9543
     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
  9544
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9545
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9546
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9547
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9548
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9549
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9550
update:aspect with:argument from:anObject
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9551
    "one of our registered handles has been collected"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9552
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9553
    aspect == #ElementExpired ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9554
	OpenFiles keysAndValuesDo:[:fd :handle |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9555
	    handle == 0 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9556
		"Have to close the file descriptor"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9557
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9558
		OperatingSystem closeFd:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9559
		OpenFiles at:fd put:nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9560
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9561
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9562
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9563
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9564
    "Created: 30.9.1997 / 12:57:35 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9565
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9566
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9567
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9568
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9569
initialize
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9570
     OpenFiles := WeakArray new:10.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9571
     OpenFiles addDependent:self.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9572
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9573
     "self initialize"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9574
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9575
    "Created: 26.9.1997 / 17:15:50 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9576
    "Modified: 30.9.1997 / 12:40:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9577
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9578
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9579
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9580
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9581
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9582
    "create an instance of myself for a given fileDescriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9583
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9584
    ^ self new for:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9585
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9586
    "Created: 30.9.1997 / 14:00:00 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9587
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9588
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9589
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9590
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9591
error:anErrorSymbolOrErrno
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9592
    "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
  9593
     or the error number as returned by the OperatingSystem"
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9594
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9595
    anErrorSymbolOrErrno isInteger ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9596
	(UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9597
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9598
    self primitiveFailed:anErrorSymbolOrErrno.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9599
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9600
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9601
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9602
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9603
close
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9604
    "close the descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9605
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9606
    |desc|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9607
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9608
    desc := fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9609
    self invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9610
    ^ OperatingSystem closeFd:desc.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9611
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9612
    "Modified: 30.9.1997 / 13:06:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9613
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9614
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9615
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9616
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9617
for:aFileDescriptor
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9618
    "create a file for a handle"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9619
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9620
    |oldHandle|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9621
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9622
    fd := aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9623
    oldHandle := OpenFiles at:aFileDescriptor.
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9624
    "/ 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
  9625
    "/ 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
  9626
    (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
  9627
	oldHandle invalidate.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9628
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9629
    self register.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9630
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9631
    "Created: 26.9.1997 / 17:14:40 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9632
    "Modified: 30.9.1997 / 12:41:43 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9633
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9634
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9635
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9636
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9637
readBytes:count into:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9638
    "read count bytes into a byte-buffer;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9639
     Return the number of bytes read.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9640
     The read is non-blocking. If the operation would block
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9641
     either an incomplete count or nil will be returned.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9642
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9643
     An exception is raised on any other error"
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9644
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9645
    |error|
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9646
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9647
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9648
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9649
    int nRead = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9650
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9651
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9652
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9653
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9654
    if (! __isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9655
	error = @symbol(errorNotOpen);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9656
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9657
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9658
    if (! __bothSmallInteger(count, firstIndex)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9659
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9660
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9661
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9662
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9663
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9664
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9665
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9666
    if (fd < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9667
	error = @symbol(internalError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9668
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
  9669
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
  9670
    if (__isExternalBytesLike(aByteBuffer)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9671
	OBJ sz;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9672
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9673
	nInstBytes = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9674
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9675
	sz = __externalBytesSize(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9676
	if (__isSmallInteger(sz)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9677
	    objSize = __smallIntegerVal(sz);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9678
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9679
	    objSize = -1; /* unknown */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9680
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9681
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9682
	OBJ oClass;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9683
	int nInstVars;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9684
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9685
	oClass = __Class(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9686
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9687
	    case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9688
	    case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9689
	    case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9690
	    case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9691
	    case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9692
	    case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9693
	    case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9694
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9695
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9696
		error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9697
		goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9698
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9699
	extPtr = (char *)0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9700
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9701
	nInstBytes = __OBJS2BYTES__(nInstVars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9702
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9703
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9704
    if ((offs >= 0)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9705
	&& (cnt >= 0)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9706
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9707
	nRead = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9708
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9709
	do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9710
	    int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9711
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9712
	    if (extPtr) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9713
		n = read(fd, extPtr+offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9714
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9715
		char *bp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9716
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9717
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9718
		 * on interrupt, anObject may be moved to another location.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9719
		 * So we recompute the byte-address here.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9720
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9721
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9722
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9723
		n = read(fd, bp + offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9724
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9725
	    if (n > 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9726
		cnt -= n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9727
		offs += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9728
		nRead += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9729
	    } else if (n == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9730
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9731
	    } else if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9732
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9733
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9734
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9735
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9736
#ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9737
		    || errno == EAGAIN
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9738
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9739
		) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9740
		     RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9741
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9742
		if (errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9743
		     error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9744
		     goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9745
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9746
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9747
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9748
	} while (cnt > 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9749
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9750
	RETURN (__mkSmallInteger(nRead));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9751
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9752
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9753
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9754
    ^ self error:error.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9755
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9756
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9757
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9758
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9759
     h := OperatingSystem openFileForRead:'/etc/hosts'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9760
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9761
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9762
     Transcript show:n; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9763
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9764
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9765
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9766
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9767
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9768
     h := OperatingSystem openFileForRead:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9769
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9770
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9771
     Transcript show:n printString; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9772
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9773
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9774
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9775
writeBytes:count from:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9776
    "write count bytes from a byte-buffer;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9777
     Return the number of bytes written (negative on error)"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9778
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9779
    |error|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9780
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9781
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9782
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9783
    int nWritten = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9784
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9785
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9786
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9787
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9788
    if (! __isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9789
	error = @symbol(errorNotOpen);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9790
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9791
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9792
    if (! __bothSmallInteger(count, firstIndex)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9793
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9794
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9795
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9796
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9797
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9798
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9799
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9800
    if (fd < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9801
	error = @symbol(internalError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9802
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
  9803
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
  9804
    if (__isExternalBytesLike(aByteBuffer)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9805
	OBJ sz;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9806
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9807
	nInstBytes = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9808
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9809
	sz = __externalBytesSize(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9810
	if (__isSmallInteger(sz)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9811
	    objSize = __smallIntegerVal(sz);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9812
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9813
	    objSize = -1; /* unknown */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9814
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9815
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9816
	OBJ oClass;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9817
	int nInstVars;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9818
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9819
	oClass = __Class(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9820
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9821
	    case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9822
	    case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9823
	    case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9824
	    case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9825
	    case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9826
	    case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9827
	    case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9828
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9829
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9830
		error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9831
		goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9832
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9833
	extPtr = (char *)0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9834
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9835
	nInstBytes = __OBJS2BYTES__(nInstVars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9836
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9837
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9838
    if ((offs >= 0)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9839
	&& (cnt >= 0)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9840
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9841
	nWritten = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9842
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9843
	do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9844
	    int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9845
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9846
	    if (extPtr) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9847
		n = write(fd, extPtr+offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9848
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9849
		char *bp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9850
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9851
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9852
		 * on interrupt, anObject may be moved to another location.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9853
		 * So we recompute the byte-address here.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9854
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9855
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9856
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9857
		n = write(fd, bp + offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9858
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9859
	    if (n > 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9860
		cnt -= n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9861
		offs += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9862
		nWritten += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9863
	    } else if (n == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9864
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9865
	    } else if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9866
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9867
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9868
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9869
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9870
#ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9871
		    || errno == EAGAIN
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9872
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9873
		) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9874
		     RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9875
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9876
		if (errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9877
		     error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9878
		     goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9879
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9880
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9881
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9882
	} while (cnt > 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9883
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9884
	RETURN (__mkSmallInteger(nWritten));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9885
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9886
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9887
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9888
    ^ self error:error
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9889
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9890
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9891
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9892
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9893
     h := OperatingSystem createFileForReadWrite:'/tmp/xx'.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9894
     buff := '12345678901234567890'.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9895
     n := h writeBytes:10 from:buff startingAt:1.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9896
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9897
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9898
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9899
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9900
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9901
     h := OperatingSystem createFileForReadWrite:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9902
     buff := '12345678901234567890'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9903
     n := h writeBytes:10 from:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9904
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9905
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9906
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9907
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9908
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9909
nextError
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9910
    "retrieve the pending error from the current fileDescriptor
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9911
     and raise an error exception.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9912
     This should be only called, when an error is pending.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9913
     Otherwise a byte may be lost"
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9914
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9915
    |dummyByte|
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9916
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9917
    dummyByte := ByteArray new:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9918
    ^ self readBytes:1 into:dummyByte startingAt:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9919
!
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9920
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9921
seekTo:newPosition from:whence
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9922
    "seek to newPosition
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9923
     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
  9924
     Return the new position."
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9925
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9926
    |error|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9927
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9928
%{
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9929
    INT fd;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9930
    INT __whence;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9931
    off_t pos, ret;
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9932
    OBJ rslt;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9933
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9934
    if (! __isSmallInteger(__INST(fd))) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9935
	error = @symbol(errorNotOpen);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9936
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9937
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9938
    if (__isSmallInteger(newPosition)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9939
	pos = __smallIntegerVal(newPosition);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9940
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9941
	pos = __signedLongIntVal(newPosition);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9942
	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
  9943
	    error = @symbol(badArgument1);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9944
	    goto bad;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9945
	}
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9946
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9947
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9948
    fd = __smallIntegerVal(__INST(fd));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9949
    if (fd < 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9950
	error = @symbol(internalError);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9951
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9952
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9953
    if (whence == @symbol(begin)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9954
	__whence = SEEK_SET;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9955
    } else if (whence == @symbol(current)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9956
	__whence = SEEK_CUR;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9957
    } else if (whence == @symbol(end)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9958
	__whence = SEEK_END;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9959
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9960
	error = @symbol(badArgument2);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9961
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9962
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9963
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9964
again:
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9965
    ret = lseek(fd, pos, __whence);
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9966
    if (ret < 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9967
	if (errno == EINTR) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9968
	    __HANDLE_INTERRUPTS__;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9969
	    goto again;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9970
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9971
	error = __mkSmallInteger(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9972
	goto bad;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9973
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9974
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9975
    if (sizeof(ret) == 8) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9976
	rslt = __MKINT64 (&ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9977
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9978
	rslt = __MKINT(ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9979
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
  9980
    RETURN (rslt);
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9981
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9982
bad: ;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9983
%}.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9984
    ^ self error:error.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9985
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9986
    "
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9987
     |h buff n|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9988
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9989
     h := OperatingSystem openFileForRead:'/etc/hosts'.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9990
     h seekTo:10 from:#begin.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9991
     buff := ByteArray new:1000. buff inspect.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9992
     n := h readBytes:1000 into:buff startingAt:1.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9993
     Transcript show:n; space; showCR:buff asString.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9994
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9995
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9996
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9997
selectWithTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9998
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9999
     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
 10000
     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
 10001
     of read-data.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10002
     Experimental."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10003
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10004
    ^ OperatingSystem selectOnAnyReadable:(Array with:fd)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10005
		      writable:(Array with:fd)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10006
		     exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10007
		   withTimeOut:millis
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10008
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10009
    "Created: 1.10.1997 / 08:51:11 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10010
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10011
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10012
setBlocking:aBoolean
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10013
    "{ Pragma: +optSpace }"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10014
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10015
    "set/clear the blocking attribute - if set (which is the default)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10016
     a read on the fileDescriptor will block until data is available.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10017
     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
 10018
     nil if no data is available."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10019
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10020
    |err|
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10021
%{
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10022
    int ret, flags;
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 defined(F_GETFL) && defined(F_SETFL)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10025
# if defined(O_NDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10026
#  define DELAY O_NDELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10027
# else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10028
#  if defined(FNDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10029
#   define DELAY FNDELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10030
#  endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10031
# endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10032
# if defined(DELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10033
    if (__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10034
	int f = __intVal(__INST(fd));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10035
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10036
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10037
	if (aBoolean == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10038
	    ret = fcntl(f, F_SETFL, flags & ~DELAY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10039
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10040
	    ret = fcntl(f, F_SETFL, flags | DELAY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10041
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10042
	if (ret >= 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10043
	    RETURN(__MKSMALLINT(flags));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10044
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10045
	    err = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10046
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10047
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10048
# undef DELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10049
# endif /* DELAY */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10050
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10051
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10052
    err notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10053
	self error:err
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10054
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10055
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10056
     fd argument not integer
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10057
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10058
    ^ self primitiveFailed
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10059
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10060
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
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 10063
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'private-accessing'!
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10064
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10065
fileDescriptor
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10066
    "return the (integer) fileDescriptor"
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10067
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10068
%{
7462
05b5202d988a Fix compiler warning
Stefan Vogel <sv@exept.de>
parents: 7461
diff changeset
 10069
    OBJ handle = __externalAddressVal(self);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10070
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10071
    if (__isSmallInteger(handle)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10072
	RETURN (handle);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10073
    }
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10074
%}.
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10075
    ^ nil
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10076
!
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10077
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10078
setFileDescriptor:anInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10079
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10080
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10081
    if (__isSmallInteger(anInteger)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10082
	__externalAddressVal(self) = (OBJ)(__smallIntegerVal(anInteger));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10083
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10084
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10085
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10086
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10087
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10088
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10089
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10090
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10091
canReadWithoutBlocking
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10092
    "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
 10093
     (i.e. read is possible without blocking).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10094
     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
 10095
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10096
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10097
    int fd;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10098
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10099
    if (__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10100
	fd = __smallIntegerVal(__INST(fd));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10101
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10102
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10103
	 * if available, try FIONREAD first, which is usually done faster.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10104
	 */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10105
# ifdef FIONREAD
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10106
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10107
	    int result = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10108
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10109
	    if (ioctl(fd, FIONREAD, &result) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10110
		RETURN(result > 0 ? true : false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10111
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10112
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10113
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10114
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10115
# if defined(__VMS__) && defined(DOES_NOT_WORK_YET)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10116
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10117
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10118
	     * do a sys$qio ..
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10119
	     * fd here is suposed to be a channel nr.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10120
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10121
	    struct IOSB iosb;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10122
	    int status;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10123
	    int channel;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10124
	    struct typahdask sensebuf;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10125
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10126
	    status = SYS$QIO(0, /* efn */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10127
			     fd,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10128
			     IO$_SENSEMODE | IO$M_TYPEAHDCNT,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10129
			     &iosb,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10130
			     0, /* ast */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10131
			     0, /* ast arg */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10132
			     &sensebuf,         /* data */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10133
			     sizeof(sensebuf),  /* data size */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10134
			     0, 0, 0, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10135
	    if (status != SS$_NORMAL) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10136
		fprintf(stderr, "OS [info]: SYS$QIO failed on %d\n", fd);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10137
	    } else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10138
		fprintf(stderr, "sys$QIO -> %d\n", sensebuf.typcnt);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10139
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10140
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10141
# endif /* __VMS__ */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10142
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10143
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10144
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10145
    OperatingSystem supportsSelect ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10146
	"/ mhmh - what should we do then ?
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10147
	"/ For now, return true as if data was present,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10148
	"/ and let the thread fall into the read.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10149
	"/ It will then (hopefully) be desceduled there and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10150
	"/ effectively polling for input.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10151
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10152
	^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10153
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10154
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10155
    ^ (OperatingSystem selectOnAnyReadable:(Array with:fd)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10156
		       writable:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10157
		       exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10158
		       withTimeOut:0) == fd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10159
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10160
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10161
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10162
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10163
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10164
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10165
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10166
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10167
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10168
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10169
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10170
     h := OperatingSystem openFileForRead:'/dev/ttyS0'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10171
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10172
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10173
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10174
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10175
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10176
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10177
canWriteWithoutBlocking
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10178
    "return true, if filedescriptor can be written without blocking"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10179
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10180
    OperatingSystem supportsSelect ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10181
	"/ mhmh - what should we do then ?
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10182
	"/ For now, return true as if data was present,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10183
	"/ and let the thread fall into the write.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10184
	"/ It will then (hopefully) be desceduled there and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10185
	"/ effectively polling for output.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10186
	^ true
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10187
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10188
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10189
    ^ (OperatingSystem selectOnAnyReadable:nil
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10190
		       writable:(Array with:fd)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10191
		       exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10192
		       withTimeOut:0) == fd
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10193
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10194
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10195
isValid
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10196
    "answer true, if the handle is valid, i.e. connected to
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10197
     a file or some other OS object"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10198
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10199
    ^ fd notNil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10200
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10201
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10202
numAvailableForRead
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10203
    "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
 10204
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10205
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10206
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10207
     * 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
 10208
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10209
# if defined(FIONREAD)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10210
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10211
	int n = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10212
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10213
	if (__isSmallInteger(__INST(fd))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10214
	    if (ioctl(__smallIntegerVal(__INST(fd)), FIONREAD, &n) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10215
		RETURN (__MKINT(n));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10216
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10217
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10218
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10219
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10220
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10221
    ^ self canReadWithoutBlocking ifTrue:[1] ifFalse:[0]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10222
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10223
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10224
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10225
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10226
     n := h numAvailableForRead.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10227
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10228
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10229
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10230
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10231
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10232
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10233
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10234
register
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10235
    "register myself as an open file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10236
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10237
    |sz old|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10238
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10239
    sz := OpenFiles size.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10240
    fd > sz ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10241
	"grow for more descriptors"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10242
	old := OpenFiles.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10243
	OpenFiles := WeakArray new:(sz * 2).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10244
	old removeDependent:(self class).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10245
	OpenFiles addDependent:(self class).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10246
	old keysAndValuesDo:[:index :elem|
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10247
	    "be careful to not overwrite new entries in OpenFiles"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10248
	    elem notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10249
		OpenFiles at:index put:elem.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10250
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10251
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10252
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10253
    OpenFiles at:fd put:self.
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
    "Created: 30.9.1997 / 12:51:48 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10256
    "Modified: 30.9.1997 / 12:58:37 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10257
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10258
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10259
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10260
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10261
invalidate
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10262
    "a file handle has become invalid"
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
    OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10265
    fd := nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10266
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10267
    "Created: 30.9.1997 / 12:37:26 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10268
    "Modified: 30.9.1997 / 12:42:16 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10269
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10270
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10271
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10272
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10273
readWaitWithTimeoutMs:timeout
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10274
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10275
     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
 10276
     If data is already available, return immediate.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10277
     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
 10278
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10279
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10280
    |inputSema hasData wasBlocked|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10281
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10282
    fd isNil ifTrue:[^ self error:#errorNotOpen].
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
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10285
    hasData := self canReadWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10286
    hasData ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10287
	inputSema := Semaphore new name:'readWait'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10288
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10289
	    timeout notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10290
		Processor signal:inputSema afterMilliseconds:timeout
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10291
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10292
	    Processor signal:inputSema onInput:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10293
	    Processor activeProcess state:#ioWait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10294
	    inputSema wait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10295
	    Processor disableSemaphore:inputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10296
	    hasData := self canReadWithoutBlocking.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10297
	] ifCurtailed:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10298
	    Processor disableSemaphore:inputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10299
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10300
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10301
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10302
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10303
    ^ hasData not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10304
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10305
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10306
writeWaitWithTimeoutMs:timeout
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10307
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10308
     becomes ready for writing or a timeout (in seconds) expired.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10309
     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
 10310
     Return immediate if the receiver is already ready.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10311
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10312
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
 10313
    |outputSema canWrite wasBlocked|
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10314
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10315
    fd isNil ifTrue:[^ self error:#errorNotOpen].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10316
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10317
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10318
    canWrite := self canWriteWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10319
    canWrite ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10320
	outputSema := Semaphore new name:'writeWait'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10321
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10322
	    timeout notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10323
		Processor signal:outputSema afterMilliseconds:timeout
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10324
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10325
	    Processor signal:outputSema onOutput:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10326
	    Processor activeProcess state:#ioWait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10327
	    outputSema wait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10328
	    Processor disableSemaphore:outputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10329
	    canWrite := self canWriteWithoutBlocking.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10330
	] ifCurtailed:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10331
	    Processor disableSemaphore:outputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10332
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10333
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10334
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10335
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10336
    ^ canWrite not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10337
! !
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10338
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10339
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10340
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10341
closeFile
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10342
    "close the underlying file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10343
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10344
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10345
    FILE *f = (FILE *)(__externalAddressVal(self));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10346
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10347
    if (f) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10348
	__externalAddressVal(self) = NULL;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10349
	fclose(f);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10350
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10351
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10352
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10353
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10354
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10355
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10356
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10357
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
 10358
    ^ self basicNew
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10359
	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
 10360
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10361
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10362
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10363
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10364
accessTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10365
    "return accessed"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10366
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10367
    accessed isInteger ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10368
	"/ lazy time conversion
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10369
	accessed := Timestamp fromOSTime:(accessed * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10370
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10371
    ^ accessed
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10372
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10373
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10374
alternativeName
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10375
    "return the files other name (DOS name on windows).
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10376
     Nil if there is no other name"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10377
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10378
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10379
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10380
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10381
creationTime
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10382
    ^ nil
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10383
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10384
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10385
fileSize
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10386
    "return size"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10387
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10388
    ^ size
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10389
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10390
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10391
fixedHeaderSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10392
    "return the fixedHeaderSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10393
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10394
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10395
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10396
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10397
gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10398
    "return gid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10399
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10400
    ^ gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10401
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10402
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10403
id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10404
    "return id"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10405
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10406
    ^ id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10407
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10408
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10409
mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10410
    "return mode"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10411
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10412
    ^ mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10413
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10414
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10415
modificationTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10416
    "return modified"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10417
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10418
    modified isInteger ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10419
	"/ lazy time conversion
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10420
	modified := Timestamp fromOSTime:(modified * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10421
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10422
    ^ modified
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10423
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10424
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10425
numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10426
    "return numLinks"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10427
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10428
    ^ numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10429
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10430
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10431
path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10432
    "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
 10433
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10434
    ^ path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10435
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10436
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10437
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10438
recordAttributes
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10439
    "return the recordAttributes (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10440
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10441
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10442
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10443
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10444
recordFormat
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10445
    "return the recordFormat (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10446
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10447
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10448
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10449
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10450
recordFormatNumeric
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10451
    "return the recordFormat as numeric (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10452
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10453
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10454
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10455
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10456
recordSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10457
    "return the recordSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10458
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10459
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10460
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10461
6372
9cd3ac764491 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6371
diff changeset
 10462
statusChangeTime
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10463
    statusChanged isInteger ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10464
	"/ lazy time conversion
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10465
	statusChanged := Timestamp fromOSTime:(statusChanged * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10466
    ].
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10467
    ^ statusChanged
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10468
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10469
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10470
type
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10471
    "return type"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10472
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10473
    ^ type
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10474
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10475
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10476
uid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10477
    "return uid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10478
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10479
    ^ uid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10480
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10481
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10482
!UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10483
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10484
accessed
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 10485
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10486
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10487
    self obsoleteMethodWarning:'use #accessTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10488
    ^ self accessTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10489
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10490
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10491
at:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10492
    "backward compatibility access: in previous releases, IdentityDictionaries
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10493
     were used to hold my information. Allow access via key messages.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10494
     This method will vanish - use the proper access protocol."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10495
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10496
    ^ self perform:key
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10497
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10498
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10499
modified
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 10500
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10501
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10502
    self obsoleteMethodWarning:'use #modificationTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10503
    ^ self modificationTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10504
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10505
6801
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10506
size
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10507
    "return size"
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10508
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10509
    ^ size
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10510
!
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10511
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10512
statusChanged
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 10513
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10514
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10515
    self obsoleteMethodWarning:'use #statusChangeTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10516
    ^ self statusChangeTime
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10517
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10518
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 10519
!UnixOperatingSystem::FileStatusInfo methodsFor:'private-accessing'!
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10520
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10521
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
 10522
    type := t.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10523
    mode := m.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10524
    uid := u.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10525
    gid := g.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10526
    size := s.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10527
    id := i.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10528
    accessed := aT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10529
    modified := mT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10530
    statusChanged := sT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10531
    path := lP.
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10532
    numLinks := nL.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10533
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10534
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10535
!UnixOperatingSystem::FileStatusInfo methodsFor:'queries'!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10536
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10537
isBlockSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10538
    ^ 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
 10539
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10540
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10541
isCharacterSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10542
    ^ 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
 10543
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10544
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10545
isDirectory
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10546
    ^ 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
 10547
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10548
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10549
isFifo
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10550
    ^ 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
 10551
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10552
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10553
isRegular
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10554
    ^ 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
 10555
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10556
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10557
isSocket
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10558
    ^ 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
 10559
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10560
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10561
isSymbolicLink
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10562
    ^ 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
 10563
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10564
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10565
isUnknown
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10566
    ^ 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
 10567
! !
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10568
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10569
!UnixOperatingSystem::MountInfo methodsFor:'accessing'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10570
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10571
mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10572
    "return the value of the instance variable 'mountPointPath' (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10573
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10574
    ^ mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10575
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10576
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10577
mountPointPath:mountPointArg deviceOrRemotePath:deviceOrRemotePathArg fsType:fsTypeArg attributeString:attributeStringArg
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10578
    "set instance variables (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10579
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10580
    mountPointPath := mountPointArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10581
    deviceOrRemotePath := deviceOrRemotePathArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10582
    fsType := fsTypeArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10583
    attributeString := attributeStringArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10584
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10585
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10586
!UnixOperatingSystem::MountInfo methodsFor:'printing'!
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10587
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10588
printOn:aStream
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10589
    aStream
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10590
	nextPutAll:'MountInfo for ';
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10591
	nextPutAll:mountPointPath.
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10592
! !
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10593
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10594
!UnixOperatingSystem::MountInfo methodsFor:'queries'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10595
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10596
isRemote
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10597
    ^ fsType = 'nfs'
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10598
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10599
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10600
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10601
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10602
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10603
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10604
    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
 10605
    operating system processes (these are no smalltalk processes!!).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10606
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10607
    [Instance variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10608
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10609
	pid     <Integer>       OS-Process identifier
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10610
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10611
	status  <Symbol>        either #exit #signal #stop #continue
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10612
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10613
	code    <Integer>       either exitcode or signalnumber
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10614
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10615
	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
 10616
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10617
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10618
    [author:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10619
	Stefan Vogel
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10620
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10621
    [see also:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10622
	OperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10623
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10624
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10625
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10626
!UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10627
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10628
pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10629
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10630
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10631
    ^ 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
 10632
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10633
    "Created: 28.12.1995 / 14:16:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10634
    "Modified: 30.4.1996 / 18:25:00 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10635
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10636
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10637
processCreationFailure
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10638
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10639
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10640
    ^ 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
 10641
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10642
    "Created: 28.12.1995 / 14:35:29 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10643
    "Modified: 30.4.1996 / 18:25:05 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10644
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10645
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10646
!UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10647
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10648
code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10649
    "return the exitcode / signalNumber"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10650
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10651
    ^ code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10652
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10653
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10654
    "Modified: 30.4.1996 / 18:26:23 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10655
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10656
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10657
core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10658
    "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
 10659
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10660
    ^ core == true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10661
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10662
    "Modified: 28.12.1995 / 14:14:38 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10663
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10664
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10665
pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10666
    "return the pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10667
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10668
    ^ pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10670
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10671
    "Modified: 30.4.1996 / 18:26:30 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10672
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10673
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10674
status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10675
    "return status as a Symbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10676
     one of #exit #signal #stop #continue"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10677
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10678
    ^ status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10679
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10680
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10681
    "Modified: 30.4.1996 / 18:26:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10682
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10683
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10684
!UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10685
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10686
pid:newPid status:newStatus code:newCode core:newCore
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10687
    pid := newPid.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10688
    status := newStatus.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10689
    code := newCode.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10690
    core := newCore.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10691
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10692
    "Created: 28.12.1995 / 14:18:22 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10693
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10694
7175
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10695
!UnixOperatingSystem::OSProcessStatus methodsFor:'printing & storing'!
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10696
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10697
printOn:aStream
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10698
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10699
    aStream nextPutAll:'ExitStatus ('.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10700
    status printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10701
    aStream nextPutAll:', code='.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10702
    code printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10703
    aStream nextPut:$).
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10704
! !
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10705
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10706
!UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10707
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10708
code:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10709
    "set the exitCode"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10710
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10711
    code := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10712
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10713
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10714
    "Modified: 30.4.1996 / 18:25:18 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10715
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10716
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10717
core:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10718
    "set core"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10719
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10720
    core := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10721
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10722
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10723
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10725
pid:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10726
    "set pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10728
    pid := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10729
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10730
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10731
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10732
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10733
status:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10734
    "set status"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10735
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10736
    status := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10737
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10738
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10739
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10740
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10741
!UnixOperatingSystem::OSProcessStatus methodsFor:'queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10742
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10743
couldNotExecute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10744
    "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
 10745
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10746
    ^ status == #exit and:[code = 127].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10747
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10748
    "Created: 28.12.1995 / 15:43:17 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10749
    "Modified: 30.4.1996 / 18:27:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10750
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10751
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10752
stillAlive
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10753
    "true if process is still alive"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10755
    ^ status == #stop or:[status == #continue]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10756
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10757
    "Created: 28.12.1995 / 14:27:26 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10758
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10759
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10760
success
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10761
    "true if process terminated successfully"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10763
    ^ status == #exit and:[code = 0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10764
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10765
    "Created: 28.12.1995 / 14:13:05 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10766
    "Modified: 28.12.1995 / 14:13:41 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10767
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10768
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10769
!UnixOperatingSystem::SocketHandle class methodsFor:'constants'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10770
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10771
protocolCodeOf:aNameOrNumber
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10772
    "convert a symbol to a numeric protocol code"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10773
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10774
    |protocolCode protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10775
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10776
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10777
    if (__isSmallInteger(aNameOrNumber) || aNameOrNumber == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10778
	RETURN(aNameOrNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10779
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10780
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10781
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10782
    ProtocolCache notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10783
	protocolCode := ProtocolCache at:(aNameOrNumber asSymbol) ifAbsent:[].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10784
	protocolCode notNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10785
	    ^ protocolCode.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10786
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10787
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10788
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10789
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10790
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10791
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10792
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10793
    if (__isString(aNameOrNumber) || __isSymbol(aNameOrNumber)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10794
	protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10795
	if (protoent) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10796
	    protocolCode = __MKSMALLINT(protoent->p_proto);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10797
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10798
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10799
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10800
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10801
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10802
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10803
    protocolSymbol notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10804
	ProtocolCache isNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10805
	    ProtocolCache := IdentityDictionary new.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10806
	].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10807
	"beware of polluting the protocol cache with aliases"
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10808
	ProtocolCache at:protocolSymbol put:protocolCode.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10809
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10810
    ^ protocolCode
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10811
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10812
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10813
     self protocolCodeOf:#tcp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10814
     self protocolCodeOf:#udp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10815
     self protocolCodeOf:#raw
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10816
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10817
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10818
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10819
protocolSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10820
    "convert a numeric protocol code to a symbol"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10821
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10822
    |protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10823
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10824
    ProtocolCache notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10825
	protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger ifAbsent:[].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10826
	protocolSymbol notNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10827
	    ^ protocolSymbol.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10828
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10829
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10830
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10831
%{
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10832
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10833
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10834
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10835
    if (__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10836
	protoent = getprotobynumber(__intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10837
	if (protoent) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10838
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10839
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10840
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10841
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10842
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10843
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10844
    protocolSymbol notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10845
	ProtocolCache isNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10846
	    ProtocolCache := IdentityDictionary new.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10847
	].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10848
	ProtocolCache at:protocolSymbol put:anInteger.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10849
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10850
    ^ protocolSymbol
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10851
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10852
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10853
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10854
     self protocolSymbolOf:(self protocolCodeOf:#tcp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10855
     self protocolSymbolOf:(self protocolCodeOf:#udp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10856
     self protocolSymbolOf:(self protocolCodeOf:#icmp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10857
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10858
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10859
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10860
!UnixOperatingSystem::SocketHandle class methodsFor:'initialization'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10861
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10862
reinitialize
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10863
    "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
 10864
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10865
    ProtocolCache := nil.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10866
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10867
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10868
!UnixOperatingSystem::SocketHandle class methodsFor:'queries'!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10869
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10870
getAddressInfo:hostName serviceName:serviceName domain:domainArg type:typeArg protocol:protoArg flags:flags
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10871
    "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
 10872
     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
 10873
     addresses to be returned."
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10874
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10875
    |error errorString result domain type proto|
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10876
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 10877
    domain := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 10878
    type := OperatingSystem socketTypeCodeOf:typeArg.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10879
    proto := self protocolCodeOf:protoArg.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10880
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10881
%{ /* STACK:32000 */
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 10882
#undef xxAI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10883
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10884
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10885
#if !defined(NO_SOCKET)
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10886
    char *__hostName, *__serviceName;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10887
    int ret, cnt = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10888
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10889
    if (hostName == nil) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10890
        __hostName = 0;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10891
    } else if (__isString(hostName) || __isSymbol(hostName)) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10892
        __hostName = __stringVal(hostName);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10893
    } else {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10894
        error = @symbol(badArgument1);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10895
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10896
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10897
    if (serviceName == nil) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10898
        __serviceName = 0;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10899
    } else if (__isString(serviceName) || __isSymbol(serviceName)) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10900
        __serviceName = __stringVal(serviceName);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10901
    } else {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10902
        error = @symbol(badArgument2);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10903
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10904
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10905
    if (__hostName == 0 && __serviceName == 0) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10906
        error = @symbol(badArgument);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10907
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10908
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10909
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10910
{
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10911
# if defined(AI_NUMERICHOST)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10912
    /*
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10913
     * Use getaddrinfo()
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10914
     */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10915
    struct addrinfo hints;
7782
c42d11aaedb1 oops: please do not forget the garbage collector when allocating
Claus Gittinger <cg@exept.de>
parents: 7767
diff changeset
 10916
    struct addrinfo *info = NULL, *infop;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10917
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10918
    memset(&hints, 0, sizeof(hints));
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10919
    if (__isSmallInteger(domain))
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10920
        hints.ai_family = __intVal(domain);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10921
    if (__isSmallInteger(type))
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10922
        hints.ai_socktype = __intVal(type);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10923
    if (__isSmallInteger(proto))
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10924
        hints.ai_protocol = __intVal(proto);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10925
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10926
    do {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10927
        __BEGIN_INTERRUPTABLE__
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10928
        ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10929
        __END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10930
    } while (ret == EAI_SYSTEM && errno == EINTR);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10931
    if (ret != 0) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10932
        switch (ret) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10933
        case EAI_FAMILY:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10934
            error = @symbol(badProtocol);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10935
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10936
        case EAI_SOCKTYPE:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10937
            error = @symbol(badSocketType);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10938
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10939
        case EAI_BADFLAGS:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10940
            error = @symbol(badFlags);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10941
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10942
        case EAI_NONAME:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10943
            error = @symbol(unknownHost);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10944
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10945
        case EAI_SERVICE:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10946
            error = @symbol(unknownService);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10947
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10948
        case EAI_ADDRFAMILY :
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10949
            error = @symbol(unknownHostForProtocol);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10950
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10951
        case EAI_NODATA:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10952
            error = @symbol(noAddress);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10953
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10954
        case EAI_MEMORY:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10955
            error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10956
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10957
        case EAI_FAIL:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10958
            error = @symbol(permanentFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10959
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10960
        case EAI_AGAIN:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10961
            error = @symbol(tryAgain);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10962
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10963
        case EAI_SYSTEM:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10964
            error = @symbol(systemError);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10965
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10966
        default:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10967
            error = @symbol(unknownError);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10968
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10969
        errorString = __MKSTRING(gai_strerror(ret));
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10970
        goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10971
    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10972
    for (cnt=0, infop=info; infop; infop=infop->ai_next)
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10973
        cnt++;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10974
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10975
    result = __ARRAY_NEW_INT(cnt);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10976
    if (result == nil) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10977
        error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10978
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10979
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10980
    for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10981
        OBJ o, resp;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10982
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10983
        resp = __ARRAY_NEW_INT(6);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10984
        if (resp == nil) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10985
            error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10986
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10987
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10988
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10989
        __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10990
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10991
        __ArrayInstPtr(resp)->a_element[0] = __MKSMALLINT(infop->ai_flags);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10992
        __ArrayInstPtr(resp)->a_element[1] = __MKSMALLINT(infop->ai_family);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10993
        __ArrayInstPtr(resp)->a_element[2] = __MKSMALLINT(infop->ai_socktype);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10994
        __ArrayInstPtr(resp)->a_element[3] = __MKSMALLINT(infop->ai_protocol);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10995
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10996
        __PROTECT__(resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10997
        o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10998
        __UNPROTECT__(resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 10999
        if (o == nil) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11000
            error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11001
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11002
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11003
        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
 11004
       __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11005
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11006
        if (infop->ai_canonname) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11007
            __PROTECT__(resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11008
            o = __MKSTRING(infop->ai_canonname);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11009
            __UNPROTECT__(resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11010
            if (o == nil) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11011
                error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11012
                goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11013
            }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11014
            __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11015
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11016
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11017
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11018
err:
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11019
    if (info) freeaddrinfo(info);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11020
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11021
# else /* ! AI_NUMERICHOST =============================================================*/
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11022
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11023
    /*
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 11024
     * Use getservbyname() / gethostByName()
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 11025
     */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11026
    struct hostent *hp;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11027
    char **addrpp;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11028
    int port = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11029
    int i;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11030
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11031
    if (__serviceName) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11032
        struct servent *sp;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11033
        char *__proto = 0;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11034
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11035
        if (__isString(protoArg) || __isSymbol(protoArg))
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11036
            __proto = __stringVal(protoArg);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11037
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11038
        sp = getservbyname(__serviceName, __proto);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11039
        if (sp == NULL) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11040
            errorString = @symbol(unknownService);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11041
            error = __mkSmallInteger(-3);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11042
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11043
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11044
        port = sp->s_port;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11045
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11046
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11047
    if (__hostName) {
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11048
#  ifdef USE_H_ERRNO
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11049
        do {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11050
            /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11051
             * uses a static data area
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11052
             */
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11053
            __BEGIN_INTERRUPTABLE__
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11054
            hp = gethostbyname(__hostName);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11055
            __END_INTERRUPTABLE__
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11056
        } while ((hp == NULL)
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11057
                  && (
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11058
                        (h_errno == TRY_AGAIN)
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11059
                      || errno == EINTR
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11060
#   ifdef IRIX5_3
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11061
                      || (errno == ECONNREFUSED)
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11062
#   endif
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11063
                     )
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11064
        );
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11065
        if (hp == 0) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11066
            switch (h_errno) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11067
            case HOST_NOT_FOUND:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11068
                errorString = @symbol(unknownHost);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11069
                break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11070
            case NO_ADDRESS:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11071
                errorString = @symbol(noAddress);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11072
                break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11073
            case NO_RECOVERY:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11074
                errorString = @symbol(permanentFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11075
                break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11076
            case TRY_AGAIN:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11077
                errorString = @symbol(tryAgain);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11078
                break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11079
            default:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11080
                errorString = @symbol(unknownError);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11081
                break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11082
            }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11083
            error = __mkSmallInteger(h_errno);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11084
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11085
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11086
#  else /* !USE_H_ERRNO */
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11087
        hp = gethostbyname(__hostName);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11088
        if (hp == 0) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11089
            errorString = @symbol(unknownHost);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11090
            error = __mkSmallInteger(-1);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11091
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11092
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11093
#  endif /* !USE_H_ERRNO*/
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11094
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11095
        if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11096
            errorString = @symbol(unknownHost);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11097
            error = __mkSmallInteger(-2);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11098
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11099
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11100
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11101
        for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11102
            cnt++;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11103
        addrpp = hp->h_addr_list;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11104
    } else {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11105
        cnt = 1;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11106
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11107
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11108
    result = __ARRAY_NEW_INT(cnt);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11109
    if (result == nil) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11110
        error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11111
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11112
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11113
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11114
    for (i = 0; i < cnt; i++) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11115
        OBJ o, resp;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11116
        struct sockaddr_in *sa;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11117
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11118
        resp = __ARRAY_NEW_INT(6);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11119
        if (resp == nil) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11120
            error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11121
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11122
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11123
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11124
        __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11125
        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11126
        __ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11127
        __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11128
        __PROTECT__(resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11129
        o = __BYTEARRAY_NEW_INT(sizeof(*sa));
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11130
        __UNPROTECT__(resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11131
        if (o == nil) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11132
            error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11133
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11134
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11135
        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11136
        sa = (struct sockaddr_in *)__byteArrayVal(o);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11137
        sa->sin_port = port;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11138
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11139
        if (__hostName) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11140
            sa->sin_family = hp->h_addrtype;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11141
            memcpy(&sa->sin_addr, *addrpp, hp->h_length);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11142
            __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11143
            if (hp->h_name) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11144
                __PROTECT__(resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11145
                o = __MKSTRING(hp->h_name);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11146
                __UNPROTECT__(resp);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11147
                if (o == nil) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11148
                    error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11149
                    goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11150
                }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11151
                __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11152
            }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11153
            addrpp++;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11154
        } else{
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11155
            __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11156
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11157
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11158
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11159
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11160
# endif /* ! AI_NUMERICHOST */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11161
}
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11162
#else /* ! HAS_SOCKET */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11163
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11164
#endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11165
%}.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11166
    error notNil ifTrue:[
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11167
        |request|
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11168
        request := SocketAddressInfo new
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11169
            domain:domainArg;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11170
            type:typeArg;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11171
            protocol:protoArg;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11172
            canonicalName:hostName;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11173
            serviceName:serviceName.
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11174
        ^ (HostNameLookupError new 
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11175
                parameter:error; 
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11176
                messageText:' - ', errorString; 
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11177
                request:request) raiseRequest.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11178
    ].
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11179
    1 to:result size do:[:i |
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11180
        |entry dom info|
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11181
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11182
        info := SocketAddressInfo new.
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11183
        entry := result at:i.
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11184
        info flags:(entry at:1).
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11185
        info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11186
        info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11187
        info protocol:(self protocolSymbolOf:(entry at:4)).
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11188
        info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11189
        info canonicalName:(entry at:6).
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11190
        result at:i put:info
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11191
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11192
    ^ result
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11193
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11194
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11195
     self getAddressInfo:'localhost' serviceName:nil
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11196
            domain:nil type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11197
     self getAddressInfo:'localhost' serviceName:nil
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11198
            domain:#inet type:#stream protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11199
     self getAddressInfo:'localhost' serviceName:nil
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11200
            domain:#inet type:#stream protocol:#tcp flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11201
     self getAddressInfo:'blurb.exept.de' serviceName:nil
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11202
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11203
     self getAddressInfo:'1.2.3.4' serviceName:'bla'
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11204
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11205
     self getAddressInfo:'localhost' serviceName:'echo'
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11206
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11207
     self getAddressInfo:nil serviceName:'echo'
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11208
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11209
     self getAddressInfo:nil serviceName:nil
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11210
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11211
     self getAddressInfo:'www.google.de' serviceName:nil
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11212
            domain:nil type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11213
     self getAddressInfo:'smc1' serviceName:nil
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11214
            domain:nil type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11215
    "
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11216
!
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11217
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11218
getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11219
    "answer an Array containing the hostName and serviceName
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11220
     in socketAddress.
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11221
     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
 11222
     this returns multiple hostnames (if appropriate)"
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11223
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11224
    |error errorString hostName serviceName|
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11225
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11226
%{  /* STACK:32000 */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11227
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11228
#undef xxNI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11229
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11230
#if !defined(NO_SOCKET)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11231
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11232
# ifndef NI_MAXHOST
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11233
#  define NI_MAXHOST 256
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11234
#  define NI_MAXSERV 64
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11235
# endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11236
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11237
    char host[NI_MAXHOST];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11238
    char service[NI_MAXSERV];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11239
    char *hp = 0, *sp = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11240
    int hsz = 0, ssz = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11241
    int ret, __flags;
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11242
    char *bp;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11243
    int nInstBytes, sockAddrSize;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11244
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11245
    if (wantHostName == true) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11246
        hp = host;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11247
        hsz = sizeof(host);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11248
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11249
    if (wantServiceName == true) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11250
        sp = service;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11251
        ssz = sizeof(service);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11252
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11253
    if (hp == 0 && sp == 0) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11254
        error = @symbol(badArgument);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11255
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11256
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11257
    if (!__isBytes(socketAddress)) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11258
        error = @symbol(badArgument1);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11259
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11260
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11261
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11262
    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11263
    sockAddrSize = __byteArraySize(socketAddress);
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11264
    sockAddrSize -= nInstBytes;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11265
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11266
    if (!__isSmallInteger(flags)) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11267
        error = @symbol(badArgument5);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11268
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11269
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11270
    __flags = __intVal(flags);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11271
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11272
#if defined(NI_NUMERICHOST)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11273
    if (useDatagram == true) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11274
        __flags |= NI_DGRAM;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11275
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11276
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11277
    {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11278
        bp = (char *)(__byteArrayVal(socketAddress));
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11279
        bp += nInstBytes;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11280
        __BEGIN_INTERRUPTABLE__
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11281
        ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11282
                          hp, hsz, sp, ssz, __flags);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11283
        __END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11284
    } while (ret == EAI_SYSTEM && errno == EINTR);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11285
    if (ret != 0) {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11286
        switch (ret) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11287
        case EAI_FAMILY:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11288
            error = @symbol(badProtocol);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11289
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11290
        case EAI_SOCKTYPE:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11291
            error = @symbol(badSocketType);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11292
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11293
        case EAI_BADFLAGS:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11294
            error = @symbol(badFlags);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11295
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11296
        case EAI_NONAME:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11297
            error = @symbol(unknownHost);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11298
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11299
        case EAI_SERVICE:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11300
            error = @symbol(unknownService);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11301
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11302
        case EAI_ADDRFAMILY :
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11303
            error = @symbol(unknownHostForProtocol);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11304
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11305
        case EAI_NODATA:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11306
            error = @symbol(noAddress);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11307
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11308
        case EAI_MEMORY:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11309
            error = @symbol(allocationFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11310
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11311
        case EAI_FAIL:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11312
            error = @symbol(permanentFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11313
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11314
        case EAI_AGAIN:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11315
            error = @symbol(tryAgain);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11316
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11317
        case EAI_SYSTEM:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11318
            error = @symbol(systemError);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11319
            break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11320
        default:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11321
            error = @symbol(unknownError);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11322
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11323
        errorString = __MKSTRING(gai_strerror(ret));
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11324
        goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11325
    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11326
# else /* ! NI_NUMERICHOST */
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11327
    {
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11328
        /*
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11329
         * Do it using gethostbyaddr()
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11330
         */
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11331
        struct sockaddr_in *sa;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11332
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11333
        if (sockAddrSize < sizeof(*sa)) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11334
            error = @symbol(badArgument1);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11335
            goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11336
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11337
        bp = (char *)(__byteArrayVal(socketAddress));
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11338
        bp += nInstBytes;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11339
        sa = (struct sockaddr_in *)bp;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11340
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11341
        if (sp) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11342
            struct servent *servp;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11343
            char *__proto = 0;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11344
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11345
            __proto = (useDatagram == true ? "udp" : "tcp");
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11346
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11347
            servp = getservbyport(sa->sin_port, __proto);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11348
            if (servp) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11349
                sp = servp->s_name;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11350
            }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11351
        }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11352
        if (hp) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11353
            struct hostent *hostp;
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11354
#  ifdef USE_H_ERRNO
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11355
            do {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11356
                /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11357
                 */
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11358
                hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11359
                /* __END_INTERRUPTABLE__ */
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11360
            } while ((hostp == NULL)
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11361
                      && ((h_errno == TRY_AGAIN)
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11362
                          || errno == EINTR
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11363
#   ifdef IRIX5_3
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11364
                          || (errno == ECONNREFUSED)
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11365
#   endif
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11366
                         )
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11367
            );
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11368
            if (hostp == 0) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11369
                switch (h_errno) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11370
                case HOST_NOT_FOUND:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11371
                    errorString = @symbol(unknownHost);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11372
                    break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11373
                case NO_ADDRESS:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11374
                    errorString = @symbol(noAddress);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11375
                    break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11376
                case NO_RECOVERY:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11377
                    errorString = @symbol(permanentFailure);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11378
                    break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11379
                case TRY_AGAIN:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11380
                    errorString = @symbol(tryAgain);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11381
                    break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11382
                default:
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11383
                    errorString = @symbol(unknownError);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11384
                    break;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11385
                }
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11386
                error = __mkSmallInteger(h_errno);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11387
                goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11388
            }
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11389
#  else /* !USE_H_ERRNO */
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11390
            hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11391
            if (hostp == 0) {
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11392
                errorString = @symbol(unknownHost);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11393
                error = __mkSmallInteger(-1);
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11394
                goto err;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11395
            }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11396
#  endif /* !USE_H_ERRNO*/
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11397
            hp = hostp->h_name;
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11398
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11399
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11400
# endif /* ! NI_NUMERICHOST */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11401
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11402
    if (hp)
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11403
        hostName = __MKSTRING(hp);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11404
    if (sp)
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11405
        serviceName = __MKSTRING(sp);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11406
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11407
#else
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11408
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11409
#endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11410
%}.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11411
    error notNil ifTrue:[
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11412
        ^ (HostAddressLookupError new 
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11413
                parameter:error; 
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11414
                messageText:' - ', errorString; 
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11415
                request:thisContext message) raiseRequest.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11416
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11417
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11418
    ^ Array with:hostName with:serviceName
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11419
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11420
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11421
     self getNameInfo:
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11422
        (self getAddressInfo:'localhost' serviceName:'echo'
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11423
                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11424
         wantHostName:true wantServiceName:true datagram:false flags:0
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11425
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11426
     self getNameInfo:
8490
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11427
        (self getAddressInfo:'exept.exept.de' serviceName:'echo'
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11428
                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11429
         wantHostName:true wantServiceName:true datagram:false flags:0
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11430
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11431
     self getNameInfo:#[1 2 3 4]
605b944693e0 Raise HostNameLookupError proceedable
Stefan Vogel <sv@exept.de>
parents: 8475
diff changeset
 11432
         wantHostName:true wantServiceName:true datagram:false flags:0
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11433
    "
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
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11436
!UnixOperatingSystem::SocketHandle methodsFor:'accepting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11437
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11438
acceptWithPeerAddressBuffer:peerOrNil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11439
    "accept a connection on a server port.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11440
     Returns a new SocketHandle or nil if the operation
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11441
     would block.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11442
     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
 11443
     of the connection peer is stored into it."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11444
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11445
    |error newFd|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11446
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11447
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11448
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11449
    int sock, newSock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11450
    struct sockaddr *sap;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11451
    int alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11452
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11453
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11454
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11455
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11456
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11457
    if (peerOrNil != nil &&
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11458
	(!__isNonNilObject(peerOrNil) ||
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11459
	 (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11460
	error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11461
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11462
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11463
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11464
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11465
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11466
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11467
    if (peerOrNil == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11468
	alen = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11469
	sap = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11470
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11471
	alen =  __byteArraySize(peerOrNil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11472
	sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11473
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11474
    newSock = accept(sock, sap, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11475
    if (newSock < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11476
	switch (errno) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11477
	case EINTR:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11478
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11479
	    goto again;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11480
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11481
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11482
	case EWOULDBLOCK:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11483
# if defined(EAGAIN) && (EAGAIN != EWOULDBLOCK)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11484
	case EAGAIN:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11485
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11486
#else
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11487
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11488
	case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11489
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11490
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11491
	    RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11492
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11493
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11494
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11495
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11496
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11497
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11498
    newFd = __mkSmallInteger(newSock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11499
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11500
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11501
#endif /* not NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11502
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11503
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11504
	^ self error:error.
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11505
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11506
    ^ self class for:newFd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11507
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11508
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11509
!UnixOperatingSystem::SocketHandle methodsFor:'binding'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11510
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11511
bindTo:socketAddress
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11512
    "low level bind -
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11513
     Set the local address of the socket"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11514
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11515
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11516
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11517
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11518
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11519
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11520
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11521
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11522
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11523
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11524
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11525
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11526
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11527
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11528
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11529
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11530
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11531
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11532
    sockaddr_size = __byteArraySize(socketAddress);
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
 11533
    sock = __smallIntegerVal(__INST(fd));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11534
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11535
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11536
    ret = bind(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11537
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11538
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11539
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11540
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11541
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11542
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11543
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11544
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11545
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11546
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11547
    err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11548
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11549
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11550
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11551
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11552
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11553
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11554
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11555
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11556
     (Socket domain:#inet type:#stream)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11557
	 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11558
	 reuseAddress:false ;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11559
     yourself
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11560
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11561
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11562
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11563
!UnixOperatingSystem::SocketHandle methodsFor:'connecting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11564
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11565
cancelConnect
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11566
    "cancel an asynchronous connect in progress"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11567
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11568
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11569
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11570
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11571
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11572
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11573
    int ret;
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 11574
    struct sockaddr sockaddr;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11575
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11576
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11577
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11578
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11579
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11580
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11581
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11582
    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11583
     * (dis-) connect by connecting to AF_UNSPEC socket
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11584
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11585
again:
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 11586
    sockaddr.sa_family = AF_UNSPEC;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11587
    ret = connect(sock, &sockaddr, sizeof(sockaddr));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11588
    if (ret < 0) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11589
       switch(errno) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11590
	   case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11591
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11592
	    case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11593
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11594
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11595
		goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11596
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11597
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11598
		error = __MKSMALLINT(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11599
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11600
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11601
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11602
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11603
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11604
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11605
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11606
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11607
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11608
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11609
    ].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11610
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11611
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11612
connectTo:socketAddress
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11613
    "low level connect; connect to a socket address.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11614
     Return true if connection has been established,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11615
     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
 11616
     completed. If an error occured, an OSError is raised"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11617
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11618
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11619
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11620
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11621
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11622
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11623
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11624
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11625
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11626
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11627
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11628
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11629
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11630
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11631
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11632
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11633
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11634
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11635
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11636
    sockaddr_size = __qSize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11637
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11638
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11639
    ret = connect(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11640
    if (ret >= 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11641
	RETURN(true)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11642
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11643
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11644
    switch(errno) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11645
	case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11646
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11647
	case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11648
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11649
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11650
	    goto again;
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11651
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11652
# if defined(EINPROGRESS) || defined(EALREADY)
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11653
#  ifdef EINPROGRESS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11654
	case EINPROGRESS:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11655
#  endif
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11656
#  ifdef EALREADY
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11657
	case EALREADY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11658
#  endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11659
	    RETURN(false);
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11660
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11661
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11662
    default:
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11663
	error = __MKSMALLINT(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11664
	break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11665
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11666
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11667
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11668
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11669
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11670
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11671
	 ^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11672
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11673
    ^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11674
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11675
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11676
     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
 11677
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11678
     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
 11679
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11680
     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
 11681
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11682
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11683
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11684
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11685
!UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11686
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11687
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
 11688
    "receive datagramm data - put address of originating host into
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11689
     anAddressBuffer, data into aBuffer. For ST-80 compatibility,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11690
     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
 11691
     the addressBytes-message (i.e. be a SocketAddress instance).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11692
     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
 11693
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11694
     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
 11695
     receiving, using #readWait or #readWaitWithTimeout:."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11696
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11697
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11698
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11699
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11700
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11701
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11702
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11703
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11704
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11705
    int alen0, alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11706
    int n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11707
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11708
    int __flags, __startIndex, __nBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11709
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11710
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11711
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11712
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11713
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11714
    if (!__isSmallInteger(startIndex) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11715
	(__startIndex = __intVal(startIndex)-1) < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11716
	if (startIndex == nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11717
	    __startIndex = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11718
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11719
	    error = @symbol(badArgument3);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11720
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11721
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11722
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11723
    if (__isSmallInteger(nBytes)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11724
	__nBytes = __intVal(nBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11725
    } else if (nBytes == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11726
	__nBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11727
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11728
	error = @symbol(badArgument4);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11729
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11730
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11731
    if (!__isInteger(flags)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11732
	error = @symbol(badArgument5);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11733
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11734
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11735
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11736
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11737
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11738
    oClass = __Class(aDataBuffer);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11739
    switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11740
	case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11741
	case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11742
	case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11743
	case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11744
	case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11745
	case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11746
	case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11747
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11748
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11749
	    error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11750
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11751
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11752
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11753
    nInstVars = __intVal(_ClassInstPtr(oClass)->c_ninstvars);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11754
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11755
    objSize = __qSize(aDataBuffer) - nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11756
    nInstBytes += __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11757
    objSize -= __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11758
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11759
    if (__nBytes >= 0 &&__nBytes < objSize) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11760
	objSize = __nBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11761
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11762
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11763
    if (socketAddress == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11764
	alen0 = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11765
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11766
	if (!__isNonNilObject(socketAddress) ||
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11767
	    (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11768
	    error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11769
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11770
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11771
	alen0 = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11772
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11773
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11774
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11775
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11776
    alen = alen0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11777
    if (alen)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11778
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11779
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11780
    n = recvfrom(sock, cp, objSize, __flags, saPtr, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11781
    if (n < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11782
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11783
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11784
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11785
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11786
	    error = __MKSMALLINT(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11787
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11788
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11789
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11790
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11791
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11792
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11793
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11794
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11795
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11796
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11797
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
 11798
    "send datagramm data - fetch address of destination host from
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11799
     anAddressBuffer, data from aDataBuffer starting at startIndex,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11800
     sending count bytes.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11801
     SocketAddress must be an instance of SocketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11802
     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
 11803
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11804
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11805
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11806
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11807
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11808
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11809
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11810
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11811
    int alen, n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11812
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11813
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11814
    int __flags;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11815
    int offs, __startIndex, __maxBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11816
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11817
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11818
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11819
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11820
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11821
    if (!__isSmallInteger(startIndex) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11822
	(__startIndex = __intVal(startIndex)-1) < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11823
	if (startIndex == nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11824
	    __startIndex = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11825
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11826
	    error = @symbol(badArgument3);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11827
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11828
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11829
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11830
    if (__isSmallInteger(maxBytes)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11831
	__maxBytes = __intVal(maxBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11832
    } else if (maxBytes == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11833
	__maxBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11834
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11835
	error = @symbol(badArgument4);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11836
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11837
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11838
    if (!__isInteger(flags)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11839
	error = @symbol(badArgument5);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11840
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11841
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11842
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11843
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11844
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11845
    oClass = __Class(aDataBuffer);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11846
    switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11847
	case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11848
	    offs = __startIndex;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11849
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11850
	case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11851
	case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11852
	    offs = __startIndex * 2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11853
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11854
	case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11855
	case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11856
	    offs = __startIndex * 4;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11857
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11858
	case LONGLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11859
	case SLONGLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11860
	    offs = __startIndex * 8;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11861
# ifdef __NEED_LONGLONG_ALIGN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11862
	    offs += 4;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11863
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11864
	case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11865
	    offs = __startIndex * sizeof(float);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11866
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11867
	case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11868
	    offs = __startIndex * sizeof(double);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11869
# ifdef __NEED_DOUBLE_ALIGN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11870
	    offs += 4;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11871
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11872
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11873
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11874
	    error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11875
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11876
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11877
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11878
    nInstVars = __smallIntegerVal(_ClassInstPtr(oClass)->c_ninstvars);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11879
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11880
    objSize = __qSize(aDataBuffer) - nInstBytes - offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11881
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11882
    if (__maxBytes >= 0 && __maxBytes < objSize) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11883
# ifdef DGRAM_DEBUG
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11884
	printf("cut off ...\n");
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11885
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11886
	objSize = __maxBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11887
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11888
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11889
    if (socketAddress == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11890
	alen = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11891
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11892
	if (! __isByteArray(socketAddress)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11893
	    error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11894
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11895
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11896
	alen = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11897
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11898
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11899
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11900
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11901
    if (alen)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11902
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11903
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes + offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11904
    n = sendto(sock, cp, objSize, __flags, saPtr, alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11905
    if (n < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11906
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11907
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11908
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11909
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11910
	    error = __MKSMALLINT(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11911
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11912
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11913
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11914
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11915
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11916
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11917
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11918
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11919
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11920
6434
f23d12900e18 category rename
Claus Gittinger <cg@exept.de>
parents: 6421
diff changeset
 11921
!UnixOperatingSystem::SocketHandle methodsFor:'initialization'!
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11922
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11923
domain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11924
    "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
 11925
     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
 11926
     All arguments must be symbols from one of
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11927
     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
 11928
     type: #SOCK_STREAM, #SOCK_DGRAM (#stream, #datagram, #raw) ..
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11929
     protocol: #tcp, #udp, #raw ..
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11930
    "
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11931
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11932
    |error domainCode typeCode protocolNumber|
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11933
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11934
    domainCode := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11935
    typeCode := OperatingSystem socketTypeCodeOf:typeArg.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11936
    protocolArg notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11937
	protocolNumber := self class protocolCodeOf:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11938
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11939
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11940
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11941
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11942
    int dom, typ, proto = 0, sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11943
    int on = 1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11944
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11945
    if (__INST(fd) != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11946
	error = @symbol(internalError);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11947
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11948
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11949
    if (! __isSmallInteger(domainCode)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11950
	error = @symbol(badArgument1);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11951
	goto err;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11952
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11953
    if (! __isSmallInteger(typeArg)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11954
	error = @symbol(badArgument2);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11955
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11956
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11957
    if (protocolNumber != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11958
	if (!__isSmallInteger(protocolNumber)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11959
	    error = @symbol(badArgument3);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11960
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11961
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11962
	proto = __smallIntegerVal(protocolNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11963
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11964
    dom = __smallIntegerVal(domainCode);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11965
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11966
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11967
     * get socket-type and protocol-type
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11968
     */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11969
    typ = __intVal(typeArg);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11970
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11971
againSocket:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11972
    sock = socket(dom, typ, proto);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11973
    if (sock < 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11974
	if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11975
	    __HANDLE_INTERRUPTS__;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11976
	    goto againSocket;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11977
	} else
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11978
# if defined(EPROTONOSUPPORT) /* for SGI */
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11979
	if (errno == EPROTONOSUPPORT && proto != 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11980
	    proto = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11981
	    goto againSocket;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11982
	} else
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11983
# endif
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11984
	{
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11985
	    error = __mkSmallInteger(errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11986
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11987
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11988
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11989
    __INST(fd) = __mkSmallInteger(sock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11990
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11991
err:;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11992
# else /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11993
    error := @symbol(notImplemented);
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11994
# endif /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11995
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11996
    error notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11997
	^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11998
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11999
    self register.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12000
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12001
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12002
     self new domain:#inet type:#stream protocol:nil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12003
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12004
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12005
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12006
!UnixOperatingSystem::SocketHandle methodsFor:'misc'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12007
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12008
getOptionsLevel:level name:name
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12009
    "answer a ByteArray containing the socket option value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12010
     named name at level"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12011
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12012
    |error bytes size|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12013
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12014
    bytes := ByteArray new:256.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12015
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12016
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12017
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12018
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12019
    int intval, sz;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12020
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12021
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12022
    if (!__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12023
	error = @symbol(badFd);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12024
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12025
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12026
    if (!__bothSmallInteger(level, name)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12027
	error = @symbol(badArgument);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12028
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12029
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12030
    if (!__isByteArray(bytes)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12031
	error = @symbol(internalError);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12032
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12033
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12034
    p = __byteArrayVal(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12035
    sz = __byteArraySize(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12036
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12037
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12038
    if (getsockopt(sock, __smallIntegerVal(level), __smallIntegerVal(name), p, &sz) < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12039
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12040
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12041
    size = __mkSmallInteger(sz);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12042
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12043
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12044
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12045
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12046
    error notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12047
	^ self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12048
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12049
    ^ bytes copyTo:size
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12050
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12051
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12052
listenFor:aNumber
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12053
    "start listening.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12054
     aNumber is the number of connect indications queues
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12055
     by the operating system"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12056
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12057
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12058
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12059
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12060
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12061
    int sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12062
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12063
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12064
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12065
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12066
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12067
    if (!__isSmallInteger(aNumber)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12068
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12069
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12070
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12071
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12072
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12073
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12074
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12075
    ret = listen(sock, __smallIntegerVal(aNumber));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12076
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12077
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12078
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12079
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12080
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12081
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12082
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12083
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12084
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12085
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12086
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12087
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12088
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12089
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12090
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12091
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12092
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12093
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12094
setOptionsLevel:level name:name value:value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12095
    "set the socket option name at level to value.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12096
     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
 12097
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12098
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12099
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12100
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12101
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12102
    int sock;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12103
    int __level, __name, intval, sz;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12104
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12105
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12106
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12107
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12108
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12109
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12110
    if (__isSmallInteger(level)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12111
	__level = __smallIntegerVal(level);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12112
    } else if (level == @symbol(SOL_SOCKET)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12113
	__level = SOL_SOCKET;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12114
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12115
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12116
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12117
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12118
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12119
    if (__isSmallInteger(name)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12120
	__name = __smallIntegerVal(name);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12121
    } else if (name == @symbol(SO_REUSEADDR)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12122
	__name = SO_REUSEADDR;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12123
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12124
	error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12125
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12126
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12127
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12128
    if (__isSmallInteger(value)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12129
	intval = __intVal(value);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12130
	p = (char *) &intval;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12131
	sz = sizeof(intval);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12132
    } else if (__isByteArray(value)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12133
	p = __byteArrayVal(value);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12134
	sz = __byteArraySize(value);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12135
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12136
	error = @symbol(badArgument3);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12137
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12138
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12139
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12140
    sock = __smallIntegerVal(__INST(fd));
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12141
    if (setsockopt(sock, __level, __name, p, sz) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12142
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12143
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12144
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12145
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12146
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12147
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12148
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12149
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12150
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12151
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12152
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12153
shutdown:anInteger
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12154
    "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
 12155
     anInteger == 0   no reads will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12156
     anInteger == 1   no writes will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12157
     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
 12158
		      Pending data is discarded. This is faster tha
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12159
		      close, which may wait until pending (written)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12160
		      data has been read by the other side"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12161
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12162
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12163
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12164
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12165
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12166
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12167
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12168
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12169
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12170
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12171
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12172
    if (!__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12173
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12174
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12175
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12176
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12177
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12178
    ret = shutdown(__smallIntegerVal(__INST(fd)), __smallIntegerVal(anInteger));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12179
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12180
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12181
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12182
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12183
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12184
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12185
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12186
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12187
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12188
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12189
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12190
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12191
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12192
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12193
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12194
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12195
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12196
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12197
!UnixOperatingSystem::SocketHandle methodsFor:'queries'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12198
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12199
getNameInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12200
    "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
 12201
     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
 12202
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12203
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12204
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12205
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12206
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12207
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12208
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12209
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12210
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12211
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12212
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12213
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12214
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12215
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12216
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12217
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12218
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12219
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12220
    sockaddr_size = __byteArraySize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12221
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12222
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12223
    ret = getsockname(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12224
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12225
	error = __MKSMALLINT(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12226
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12227
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12228
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12229
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12230
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12231
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12232
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12233
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12234
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12235
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12236
getPeerInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12237
    "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
 12238
     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
 12239
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12240
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12241
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12242
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12243
#ifndef NO_SOCKET
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12244
    int __sock;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12245
    int __sockaddr_size;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12246
    int __ret;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12247
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12248
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12249
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12250
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12251
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12252
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12253
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12254
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12255
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12256
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12257
    __sockaddr_size = __byteArraySize(socketAddress);
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12258
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12259
    __sock = __smallIntegerVal(__INST(fd));
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12260
    __ret = getpeername(__sock, (struct sockaddr *)__byteArrayVal(socketAddress),
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12261
				&__sockaddr_size);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12262
    if (__ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12263
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12264
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12265
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12266
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12267
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12268
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12269
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12270
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12271
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12272
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12273
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12274
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12275
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12276
version
8618
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
 12277
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.219 2004-10-01 19:50:42 cg Exp $'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12278
! !
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 12279
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12280
UnixOperatingSystem initialize!
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 12281
UnixOperatingSystem::FileDescriptorHandle initialize!