UnixOperatingSystem.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Oct 2003 00:02:18 +0200
changeset 7681 7c63f0b47f0d
parent 7656 298c12201aa3
child 7698 d8cd175e8e29
permissions -rw-r--r--
oops: millisecondDelay: was duplicated
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:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    17
	classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    18
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    19
	category:'OS-Unix'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    20
!
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    21
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    22
Object subclass:#FileDescriptorHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    23
	instanceVariableNames:'fd'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    24
	classVariableNames:'OpenFiles'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    25
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    26
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    27
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    28
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    29
OSFileHandle subclass:#FilePointerHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    30
	instanceVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    31
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    32
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    33
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    34
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    35
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    36
Object subclass:#FileStatusInfo
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    37
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    38
		numLinks'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    39
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    40
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    41
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    44
Object subclass:#MountInfo
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    45
	instanceVariableNames:'mountPointPath deviceOrRemotePath fsType attributeString'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    46
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    47
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    48
	privateIn:UnixOperatingSystem
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    49
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    50
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    51
Object subclass:#OSProcessStatus
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    52
	instanceVariableNames:'pid status code core'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    53
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    54
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    55
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    58
UnixOperatingSystem::FileDescriptorHandle subclass:#SocketHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    59
	instanceVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    60
	classVariableNames:'ProtocolCache'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    61
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    62
	privateIn:UnixOperatingSystem
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    63
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    64
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
!UnixOperatingSystem primitiveDefinitions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
#if defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
# ifndef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
#  define WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
#ifdef LINUX
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    77
# define __xxUSE_GNU      /* new */
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    78
# undef HAS_UTS_DOMAINNAME
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
    79
# define NET_IF_SUPPORT
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    80
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    81
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    82
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    83
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    84
# endif
3956
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    85
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    86
# ifndef _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    87
#  include <sys/types.h>
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    88
#  define _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    89
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
  /* use inline string macros */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
# define __STRINGDEFS__
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
    92
# include "linuxIntern.h"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
# define WANT_SHM
3544
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
    98
# define HAS_SETENV
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
    99
# define HAS_UNSETENV
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
   100
# include <time.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
#endif
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
#ifdef IRIX5
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
#ifdef ultrix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
#ifdef hpux
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
#ifdef solaris
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
#if defined(SYSV4) && defined(i386) /* e.g. unixware */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
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
 * notice: although many systems' include files
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
 * already block against multiple inclusion, some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
 * do not. Therefore, this is done here again.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
 * (it does not hurt)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
 */ 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
#ifdef WANT_REALPATH
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
# ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
#  include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
#  define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
# include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
# define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
# include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
# define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
#endif /* WANT_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
extern int shmctl(), shmget(), shmdt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
extern char * shmat();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
# include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
# define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
# include <sys/ipc.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
# define _SYS_IPC_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
# include <sys/shm.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
# define _SYS_SHM_H_INCLUDED_
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
#endif /* WANT_SHM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
# include <sys/syssgi.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
#endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
#ifdef transputer
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
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
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
#else /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
# endif
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
# ifdef SYSV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
#  ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
#   include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
#   define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
#  ifndef _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
#   ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
#    include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
#    define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
#  ifndef _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
#   include <sys/times.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
#   define _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
#  ifndef _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
#   include <sys/file.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
#   define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
#  if ! defined(sco3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
#   ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
#    include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
#    define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
#  if defined(isc3_2) || defined(sco3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
#   ifndef _SYS_TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
#    include <sys/time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
#    define _SYS_TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
#  if !defined(isc3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
#   if defined(PCS) && defined(mips)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
#    include "/usr/include/bsd/sys/time.h"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
#    include "/usr/include/sys/time.h"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
#    ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
#     include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
#     define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
#    endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
#  if defined(isc3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
#   include <sys/bsdtypes.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
# else /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   232
#  ifndef _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   233
#   include <sys/time.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   234
#   define _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   235
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   236
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   237
#  ifndef _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   238
#   include <sys/types.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   239
#   define _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   240
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   241
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
# endif /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
# ifdef aix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
#  ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
#   include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
#   define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
#  ifndef _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
#   include <sys/select.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
#   define _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
#  endif
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
# endif /* aix */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   258
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   259
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   260
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   261
# endif
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   262
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   263
# ifndef _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   264
#  include <pwd.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   265
#  define _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   266
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   267
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   268
# ifndef NO_GRP_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   269
#  ifndef _GRP_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   270
#   include <grp.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   271
#   define _GRP_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
#  endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   273
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   274
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
# ifndef _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
#  include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
#  define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
# ifndef _SYS_FILE_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   282
#  include <sys/file.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
#  define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
# ifndef _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
#  include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
#  define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
# ifndef _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
#  include <fcntl.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
#  define _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   296
# ifndef _SYS_IOCTL_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   297
#  include <sys/ioctl.h>
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   298
#  define _SYS_IOCTL_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
# if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
#  define HAS_LOCALECONV
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
# if defined (HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
#  ifndef _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
#   include <locale.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
#   define _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   312
# if defined (HAS_FTIME)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   313
#  include <sys/timeb.h>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   314
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   315
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
/* 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
 * posix systems should define these ... 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
 * but on some (older) systems, they are not.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
#  ifdef S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
#   define S_IXUSR S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
#   define S_IXGRP (S_IEXEC>>3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
#   define S_IXOTH (S_IEXEC>>6)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
#  define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
#  define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
#  define S_IXOTH 0001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
# ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
#  define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
#  define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
#  define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
# ifndef S_IWUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
#  define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
#  define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
#  define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
# ifndef MAXPATHLEN
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   347
#  ifndef NO_SYS_PARAM_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   348
#   include <sys/param.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
#  ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
#   ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
#    define MAXPATHLEN FILENAME_MAX
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
#    ifdef MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
#     define MAXPATHLEN MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
#    else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
#     define MAXPATHLEN 1024
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
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
# if defined(HAS_UNAME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
#  include <sys/utsname.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
# if defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
#  include <stropts.h>
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
4285
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   371
# ifndef aix
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   372
#  include <sys/termios.h>
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   373
# endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   374
3496
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
 * NeXT has no pid_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
 * and no sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
# ifdef NEXT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
   typedef int pid_t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
#  define sigemptyset(set)      ((*(set) = 0L), 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
#  define HAS_GETDOMAINNAME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
#  define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
# ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
#  undef NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
#  undef HAS_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
#  define HAS_WAIT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
#  define HAS_SIGACTION
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
 * some (BSD ?) have no timezone global,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
 * but provide the info in struct timezone.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
# if defined(ultrix) || defined(sunos) || defined(NEXT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
#  define HAS_NO_TIMEZONE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
 * 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
   403
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
# ifndef SA_RESTART
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
#  define SA_RESTART    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
# ifndef SA_SIGINFO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
#  define SA_SIGINFO    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
# endif
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
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
# if defined(HAS_SYSINFO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
#  include <sys/systeminfo.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   419
# ifdef LINUX
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   420
#  include <linux/kernel.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   421
#  include <linux/sys.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   422
# endif
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   423
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   424
# if defined(HAS_GETSYSINFO)
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   425
#  include <sys/sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   426
#  include <machine/hal_sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   427
#  include <machine/hal/cpuconf.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   428
# endif
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   429
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   430
# if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   431
#  ifndef _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   432
#   include <unistd.h>
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   433
#   define _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   434
#  endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   435
# endif
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   436
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
#endif /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
 * 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
   441
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
#ifndef errno
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
 extern errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
 * some (old ?) systems do not define this ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
#if !defined(R_OK) && !defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
# define R_OK    4       /* Test for Read permission */ 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
# define W_OK    2       /* Test for Write permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
# define X_OK    1       /* Test for eXecute permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
# 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
   454
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   456
#define SIGHANDLER_ARG
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
#ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
#ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
 * 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
   467
 * explicit add of those we know to have ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
#ifdef __osf__
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
# define TIME_T time_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
# define OFF_T  off_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
#ifndef TIME_T
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
# define TIME_T long
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
#ifndef OFF_T
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
# define OFF_T  long
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
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
 * where is the timezone info ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
 */
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   484
#ifdef HAS_TM_GMTOFF
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   485
# define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   486
#else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   487
# if defined(HAS_NO_TIMEZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   488
#  if defined(HAS_NO_TM_GMTOFF)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   489
#   define TIMEZONE(tmPtr)       0
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   490
#  else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   491
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   492
#  endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
# else
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   494
#  if defined(HAS_ALTZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   495
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : altzone)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   496
#  else  /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   497
#   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
   498
#  endif /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   499
# endif
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   500
#endif                                                                                                                                                                                                                                                                                                                                                                                                                               
3595
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   501
#ifndef CONST
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   502
# ifdef __GNUC__
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   503
#  define CONST const
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   504
# else
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   505
#  define CONST /* nothing */
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   506
# endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   507
#endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   508
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   509
#ifndef        FORK
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   510
# if defined(HAS_VFORK)
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   511
#  define     FORK            vfork
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   512
# else
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   513
#  define     FORK            fork
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   514
# endif
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   515
#endif
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   516
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   517
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   518
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   519
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   520
 * Socket defines
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   521
 */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
   522
#include "stxOSDefs.h"
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
   523
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   524
#ifdef NET_IF_SUPPORT  /* for mac address of interfaces */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   525
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   526
# ifndef _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   527
#  include <net/if.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   528
#  define _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   529
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   530
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   531
# ifndef _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   532
#  include <sys/ioctl.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   533
#  define _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   534
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   535
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   536
#endif /* NET_IF_SUPPORT */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   537
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   538
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   539
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   540
#if defined(TRY_AGAIN) || defined(HOST_NOT_FOUND)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   541
# define USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   542
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   543
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   544
#ifdef USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   545
# ifndef h_errno
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   546
 extern h_errno;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   547
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   548
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   549
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
!UnixOperatingSystem primitiveFunctions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
 * some systems' system() is broken in that it does not correctly 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
 * handle EINTR and returns failure even though it actually succeeded. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
 * (LINUX is one of them)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
 * 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
   561
 * UnixOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
 * 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
   563
 *
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
 * 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
   565
 * 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
   566
 * (i.e. it is RT safe)
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
#if defined(WANT_SYSTEM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
/* # define DPRINTF(x)     printf x */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
# define DPRINTF(x)     /* nothing */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
# ifndef _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
#  include <stddef.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
#  define _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
# ifndef _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
#  include <stdlib.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
#  define _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
# endif
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
# ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
#  include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
#  define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
# ifndef _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
#  define _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
# ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
#  include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
#  define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
# 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
   605
#  define       __environ       environ
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   606
#  if 1 /* !defined(LINUX) */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
#   define      __sigemptyset   sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
#   define      __sigaction     sigaction
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
#   define      __sigaddset     sigaddset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
#   define      __sigprocmask   sigprocmask
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
#   define      __execve        execve
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
#   define      __wait          wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
#   define      __waitpid       waitpid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
#  endif /* ! LINUX */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
   extern char **environ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   618
# define      __sigprocmask   sigprocmask
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   619
# define      __execve        execve
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   620
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
# 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
   622
# define        SHELL_NAME      "sh"            /* Name to give it.  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
static int
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
mySystem(line)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
    register CONST char *line;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
    int status, save;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
    pid_t pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    struct sigaction sa, intr, quit;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
    sigset_t block, omask;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    if (line == NULL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   635
	return -1;
3496
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
    sa.sa_handler = SIG_IGN;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
    sa.sa_flags = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
    __sigemptyset (&sa.sa_mask);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   642
	DPRINTF(("1: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   643
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   646
	save = errno;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   647
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   648
	errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   649
	DPRINTF(("2: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   650
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
    __sigemptyset (&block);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
    __sigaddset (&block, SIGCHLD);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   657
	if (errno == ENOSYS)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   658
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   659
	else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   660
	    save = errno;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   661
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   662
	    (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   663
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   664
	    DPRINTF(("3: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   665
	    return -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   666
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
    pid = FORK ();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
    if (pid == (pid_t) 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   671
	/* Child side.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   672
	CONST char *new_argv[4];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   673
	new_argv[0] = SHELL_NAME;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   674
	new_argv[1] = "-c";
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   675
	new_argv[2] = line;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   676
	new_argv[3] = NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   677
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   678
	/* Restore the signals.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   679
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   680
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   681
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   682
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   683
	/* Exec the shell.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   684
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   685
	_exit (127);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   687
	if (pid < (pid_t) 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   688
	    /* The fork failed.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   689
	    DPRINTF(("4: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   690
	    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   691
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   692
	    /* Parent side.  */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
#ifdef  NO_WAITPID
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   694
	    pid_t child;
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
	    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   697
		__BEGIN_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   698
		child = __wait (&status);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   699
		__END_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   700
		if (child < 0 && errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   701
		    DPRINTF(("5: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   702
		    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   703
		    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   704
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   705
	    } while (child != pid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
#else
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
	    /* claus: the original did not care for EINTR here ... */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   710
	    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   711
		__BEGIN_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   712
		child = __waitpid (pid, &status, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   713
		__END_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   714
	    } while ((child != pid) && (errno == EINTR));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   715
	    if (child != pid) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   716
		DPRINTF(("6: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   717
		status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   718
	    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
#endif /* NO_WAITPID */
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   720
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   726
	if (errno == ENOSYS) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   727
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   728
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   729
	    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   730
	    DPRINTF(("7: errno=%d\n", errno));
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
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
    return status;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   736
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
# define __wait wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
#endif /* WANT_SYSTEM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
 * some systems do not have realpath();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
 * the alternative of reading from a 'pwp'-pipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
 * 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
   745
 * 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
   746
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
#if defined(HAS_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
#endif
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
#if defined(WANT_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
# ifndef NULL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
#  define NULL (char *)0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
# endif
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
# define MAX_READLINKS 32
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
# ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
#  define MAXPATHLEN     1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   765
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   766
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
static
6357
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   768
char *
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   769
realpath(path, resolved_path)
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   770
    char *path;
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   771
    char resolved_path [];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
{
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   773
	char copy_path[MAXPATHLEN];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   774
	char link_path[MAXPATHLEN];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   775
	char *new_path = resolved_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   776
	char *max_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   777
	int readlinks = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   778
	int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   779
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   780
	/* 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
   781
	strcpy(copy_path, path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   782
	path = copy_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   783
	max_path = copy_path + MAXPATHLEN - 2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   784
	/* 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
   785
	if (*path != '/') {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
#ifdef HAS_GETCWD
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   787
		new_path = getcwd(new_path, MAXPATHLEN - 1);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
#else
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   789
		new_path = getwd(new_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   790
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   791
		if (new_path == NULL) 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   792
		    return(NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   793
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   794
		new_path += strlen(new_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   795
		if (new_path[-1] != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   796
			*new_path++ = '/';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   797
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   798
	else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   799
		*new_path++ = '/';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   800
		path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   801
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   802
	/* Expand each slash-separated pathname component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   803
	while (*path != '\0') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   804
		/* Ignore stray "/". */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   805
		if (*path == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   806
			path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   807
			continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   808
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   809
		if (*path == '.') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   810
			/* Ignore ".". */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   811
			if (path[1] == '\0' || path[1] == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   812
				path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   813
				continue;
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
			if (path[1] == '.') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   816
				if (path[2] == '\0' || path[2] == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   817
					path += 2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   818
					/* Ignore ".." at root. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   819
					if (new_path == resolved_path + 1)
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
					/* Handle ".." by backing up. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   822
					while ((--new_path)[-1] != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   823
						;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   824
					continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   825
				}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   826
			}
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
		/* Safely copy the next pathname component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   829
		while (*path != '\0' && *path != '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   830
			if (path > max_path) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   831
				errno = ENAMETOOLONG;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   832
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   833
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   834
			*new_path++ = *path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   835
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
#ifdef S_IFLNK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   837
		/* Protect against infinite loops. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   838
		if (readlinks++ > MAX_READLINKS) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   839
			errno = ELOOP;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   840
			return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   841
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   842
		/* See if latest pathname component is a symlink. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   843
		*new_path = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   844
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   845
		if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   846
			/* 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
   847
			if (errno != EINVAL)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   848
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   849
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   850
		else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   851
			/* Note: readlink doesn't add the null byte. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   852
			link_path[n] = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   853
			if (*link_path == '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   854
				/* Start over for an absolute symlink. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   855
				new_path = resolved_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   856
			else
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   857
				/* Otherwise back up over this component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   858
				while (*(--new_path) != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   859
					;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   860
			/* Safe sex check. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   861
			if (strlen(path) + n >= MAXPATHLEN) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   862
				errno = ENAMETOOLONG;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   863
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   864
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   865
			/* Insert symlink contents into path. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   866
			strcat(link_path, path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   867
			strcpy(copy_path, link_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   868
			path = copy_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   869
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
#endif /* S_IFLNK */
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   871
		*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
	/* 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
   874
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   875
		new_path--;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   876
	/* Make sure it's null terminated. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   877
	*new_path = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   878
	return resolved_path;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
# define HAS_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
#endif /* WANT_REALPATH && not HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
copyright
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
 COPYRIGHT (c) 1988 by Claus Gittinger
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   891
	      All Rights Reserved
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
 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
   894
 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
   895
 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
   896
 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
   897
 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
   898
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   904
    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
   905
    some of it is very specific for unix, so do not depend on
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
    things available here in your applications 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
    - 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
   908
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   909
    (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
   910
     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
   911
     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
   912
     You decide - portability vs. functionality)
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
    [Class variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   915
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   916
	HostName        <String>        remembered hostname
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   917
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   918
	DomainName      <String>        remembered domainname
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   919
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   920
	SlowFork        <Boolean>       if set, fork and popen are avoided;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   921
					(more or less obsolete now)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   922
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   923
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   924
	CurrentDirectory <String>       remembered currentDirectories path
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
    [author:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   927
	Claus Gittinger
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
    [see also:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   930
	OSProcessStatus
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   931
	Filename Date Time
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   932
	ExternalStream FileStream PipeStream Socket
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   934
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   935
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   936
examples
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
  various queries
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   939
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   940
    Transcript 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   941
	showCR:'hello ' , (OperatingSystem getLoginName)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   942
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   943
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   944
								[exBegin]
3793
aff27e755ffd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   945
    OperatingSystem isUNIXlike ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   946
	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
   947
    ] ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   948
	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
   949
    ]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   950
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   951
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   952
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
    Transcript 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   954
	showCR:'this machine is called ' , OperatingSystem getHostName
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]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   958
    Transcript 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   959
	showCR:('this machine is in the '
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   960
	       , OperatingSystem getDomainName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   961
	       , ' domain')
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   962
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   963
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   964
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
    Transcript 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   966
	showCR:('this machine''s CPU is a '
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   967
	       , OperatingSystem getCPUType
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   968
	       )
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   969
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   970
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   971
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
    Transcript showCR:'executing ls command ...'.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
   973
    OperatingSystem executeCommand:'ls'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
    Transcript showCR:'... done.'.
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   975
								[exEnd]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
  locking a file 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
  (should be executed on two running smalltalks - not in two threads):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   979
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
    |f|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
    f := 'testFile' asFilename readWriteStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
    10 timesRepeat:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   985
	'about to lock ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   986
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   987
	  OperatingSystem 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   988
	    lockFD:(f fileDescriptor)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   989
	    shared:false
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   990
	    blocking:false
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   991
	] whileFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   992
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   993
	    Delay waitForSeconds:1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   994
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   995
	'LOCKED ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   996
	Delay waitForSeconds:10.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   997
	'unlock ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   998
	(OperatingSystem 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   999
	    unlockFD:(f fileDescriptor)) printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1000
	Delay waitForSeconds:3.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
    ]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1002
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
!UnixOperatingSystem class methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
initialize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
    "initialize the class"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
    ObjectMemory addDependent:self.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
    HostName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
    DomainName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
    LastErrorNumber := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
    PipeFailed := false.
4395
53122eb3ce70 clear ForkFailed flag; made it a classVar
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1016
    ForkFailed := false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
    SlowFork := false.
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1018
    CurrentDirectory := nil.
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1019
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1020
    "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
  1021
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
update:something with:aParameter from:changedObject
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
    "catch image restart and flush some cached data"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
    something == #earlyRestart ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1027
	"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1028
	 flush cached data/info
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1029
	"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1030
	HostName := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1031
	DomainName := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1032
	LastErrorNumber := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1033
	PipeFailed := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1034
	SlowFork := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1035
	ForkFailed := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1036
	CurrentDirectory := nil.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1039
    "Created: / 15.6.1996 / 15:22:37 / cg"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1040
    "Modified: / 7.1.1997 / 19:36:11 / stefan"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1041
    "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
  1042
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
!UnixOperatingSystem class methodsFor:'OS signal constants'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
sigABRT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
    "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
  1048
     (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
  1049
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1050
    ^ self signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1051
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1052
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1053
     OperatingSystem sigABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1054
    "
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
sigALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
    "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
  1059
     (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
  1060
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1061
    ^ self signalNamed:#SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1062
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1063
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1064
     OperatingSystem sigALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1065
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
sigBREAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
    "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
  1070
     This is an MSDOS specific signal"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1072
    ^ self signalNamed:#SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1073
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1074
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1075
     OperatingSystem sigBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1076
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
sigBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
    "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
  1081
     (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
  1082
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1083
    ^ self signalNamed:#SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1084
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1085
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1086
     OperatingSystem sigBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1087
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
sigCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
    "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
  1092
     (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
  1093
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1094
    ^ self signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1095
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1096
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1097
     OperatingSystem sigCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1098
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
sigCONT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
    "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
  1103
     (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
  1104
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1105
    ^ self signalNamed:#SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1106
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1107
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1108
     OperatingSystem sigCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1109
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
sigDANGER
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
    "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
  1114
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1116
    ^ self signalNamed:#SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1117
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1118
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1119
     OperatingSystem sigDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1120
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
sigEMT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
    "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
  1125
     (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
  1126
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1127
    ^ self signalNamed:#SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1128
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1129
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1130
     OperatingSystem sigEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1131
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
sigFP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    "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
  1136
     (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
  1137
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1138
    ^ self signalNamed:#SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1139
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1140
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1141
     OperatingSystem sigFP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1142
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
sigGRANT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
    "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
  1147
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1149
    ^ self signalNamed:#SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1150
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1151
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1152
     OperatingSystem sigGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1153
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
sigHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
    "return the signal number for SIGHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
     (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
  1159
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1160
    ^ self signalNamed:#SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1161
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1162
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1163
     OperatingSystem sigHUP
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
!
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
sigILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
    "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
  1170
     (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
  1171
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1172
    ^ self signalNamed:#SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1173
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
     OperatingSystem sigILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1176
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
sigINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
    "return the signal number for SIGINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
     (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
  1182
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1183
    ^ self signalNamed:#SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1184
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1185
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1186
     OperatingSystem sigINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1187
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
sigIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
    "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
  1192
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1194
    ^ self signalNamed:#SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1195
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1196
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1197
     OperatingSystem sigIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1198
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
sigIOT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1202
    "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
  1203
     (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
  1204
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1205
    ^ self signalNamed:#SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1206
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1207
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1208
     OperatingSystem sigIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1209
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1211
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
sigKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
    "return the signal number for SIGKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
     (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
  1215
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1216
    ^ self signalNamed:#SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1217
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1218
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1219
     OperatingSystem sigKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1220
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1223
sigLOST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
    "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
  1225
     (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
  1226
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1227
    ^ self signalNamed:#SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1228
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1229
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1230
     OperatingSystem sigLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1231
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1232
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1233
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1234
sigMIGRATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
    "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
  1236
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1238
    ^ self signalNamed:#SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1239
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1240
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1241
     OperatingSystem sigMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1242
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
sigMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1246
    "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
  1247
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1249
    ^ self signalNamed:#SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1250
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1251
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1252
     OperatingSystem sigMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1253
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1254
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1255
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1256
sigPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1257
    "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
  1258
     (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
  1259
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1260
    ^ self signalNamed:#SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1261
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1262
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1263
     OperatingSystem sigPIPE
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1266
!
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
sigPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
    "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
  1270
     (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
  1271
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1272
    ^ self signalNamed:#SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1273
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
     OperatingSystem sigPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1276
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1277
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1278
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1279
sigPRE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1280
    "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
  1281
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1283
    ^ self signalNamed:#SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1284
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1285
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1286
     OperatingSystem sigPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1287
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1288
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1289
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1290
sigPROF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
    "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
  1292
     (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
  1293
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1294
    ^ self signalNamed:#SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1295
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1296
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1297
     OperatingSystem sigPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1298
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1299
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1300
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1301
sigPWR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1302
    "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
  1303
     (not available on all systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1305
    ^ self signalNamed:#SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1306
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1307
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1308
     OperatingSystem sigPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1309
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1310
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
sigQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1313
    "return the signal number for SIGQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
     (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
  1315
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1316
    ^ self signalNamed:#SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1317
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1318
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1319
     OperatingSystem sigQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1320
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1321
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
sigRETRACT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1324
    "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
  1325
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1327
    ^ self signalNamed:#SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1328
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1329
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1330
     OperatingSystem sigRETRACT
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1333
!
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
sigSAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1336
    "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
  1337
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1339
    ^ self signalNamed:#SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1340
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1341
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1342
     OperatingSystem sigSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1343
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1344
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
!
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
sigSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1348
    "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
  1349
     (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
  1350
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1351
    ^ self signalNamed:#SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1352
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
     OperatingSystem sigSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1355
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1356
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1357
!
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
sigSOUND
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
    "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
  1361
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1363
    ^ self signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1364
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
     OperatingSystem sigSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1367
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1368
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1369
!
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
sigSTOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1372
    "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
  1373
     (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
  1374
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1375
    ^ self signalNamed:#SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1376
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
     OperatingSystem sigSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1379
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1380
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
sigSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
    "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
  1384
     (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
  1385
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1386
    ^ self signalNamed:#SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1387
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1388
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1389
     OperatingSystem sigSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1390
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1392
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1393
sigTERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
    "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
  1395
     (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
  1396
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1397
    ^ self signalNamed:#SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1398
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1399
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1400
     OperatingSystem sigTERM
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1403
!
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
sigTRAP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
    "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
  1407
     (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
  1408
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1409
    ^ self signalNamed:#SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1410
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1411
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1412
     OperatingSystem sigTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1413
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1414
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1415
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1416
sigTSTP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1417
    "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
  1418
     (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
  1419
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1420
    ^ self signalNamed:#SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1421
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1422
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1423
     OperatingSystem sigTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1424
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1426
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1427
sigTTIN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
    "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
  1429
     (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
  1430
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1431
    ^ self signalNamed:#SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1432
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1433
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1434
     OperatingSystem sigTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1435
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1436
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1437
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1438
sigTTOU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
    "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
  1440
     (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
  1441
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1442
    ^ self signalNamed:#SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1443
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1444
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1445
     OperatingSystem sigTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1446
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1447
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1448
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
sigURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
    "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
  1451
     (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
  1452
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1453
    ^ self signalNamed:#SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1454
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1455
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1456
     OperatingSystem sigURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1457
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
sigUSR1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
    "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
  1462
     (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
  1463
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1464
    ^ self signalNamed:#SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1465
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1466
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1467
     OperatingSystem sigUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1468
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1469
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1470
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1471
sigUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
    "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
  1473
     (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
  1474
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1475
    ^ self signalNamed:#SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1476
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1477
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1478
     OperatingSystem sigUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1479
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1480
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1481
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
sigVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1483
    "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
  1484
     (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
  1485
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1486
    ^ self signalNamed:#SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1487
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1488
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1489
     OperatingSystem sigVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1490
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
sigWINCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
    "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
  1495
     (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
  1496
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1497
    ^ self signalNamed:#SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1498
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1499
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1500
     OperatingSystem sigWINCH
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
!
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
sigXCPU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
    "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
  1507
     (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
  1508
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1509
    ^ self signalNamed:#SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1510
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1511
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1512
     OperatingSystem sigXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1513
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1514
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1515
!
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
sigXFSZ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1518
    "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
  1519
     (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
  1520
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1521
    ^ self signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1522
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
     OperatingSystem sigXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1525
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1526
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1527
!
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1528
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1529
signalNamed:signalName
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1530
    "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
  1531
     Return 0 if that signal is not supported by the OS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1532
     (NOTICE: the numeric value is not the same across unix-systems, 
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1533
      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
  1534
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1535
%{  /* NOCONTEXT */
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1536
#ifdef SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1537
    if (signalName == @symbol(SIGABRT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1538
	RETURN ( __MKSMALLINT(SIGABRT) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1541
#ifdef SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1542
    if (signalName == @symbol(SIGALRM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1543
	RETURN ( __MKSMALLINT(SIGALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1544
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1545
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1546
#ifdef SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1547
    if (signalName == @symbol(SIGBREAK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1548
	RETURN ( __MKSMALLINT(SIGBREAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1549
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1550
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1551
#ifdef SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1552
    if (signalName == @symbol(SIGBUS)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1553
	RETURN ( __MKSMALLINT(SIGBUS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1554
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1555
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1556
#ifdef SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1557
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1558
     || (signalName == @symbol(SIGCLD)) ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1559
	RETURN ( __MKSMALLINT(SIGCHLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1560
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
#else
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1562
# if defined(SIGCLD)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1563
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1564
     || (signalName == @symbol(SIGCLD)) ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1565
	RETURN ( __MKSMALLINT(SIGCLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1566
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1567
# endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1568
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1569
#ifdef SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1570
    if (signalName == @symbol(SIGCONT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1571
	RETURN ( __MKSMALLINT(SIGCONT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1572
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1573
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1574
#ifdef SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1575
    if (signalName == @symbol(SIGDANGER)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1576
	RETURN ( __MKSMALLINT(SIGDANGER) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1577
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1578
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1579
#ifdef SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1580
    if (signalName == @symbol(SIGEMT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1581
	RETURN ( __MKSMALLINT(SIGEMT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1582
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1583
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1584
#ifdef SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1585
    if (signalName == @symbol(SIGFPE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1586
	RETURN ( __MKSMALLINT(SIGFPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1587
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1588
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1589
#ifdef SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1590
    if (signalName == @symbol(SIGGRANT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1591
	RETURN ( __MKSMALLINT(SIGGRANT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1592
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1593
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1594
#ifdef SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1595
    if (signalName == @symbol(SIGHUP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1596
	RETURN ( __MKSMALLINT(SIGHUP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1597
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1598
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1599
#ifdef SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1600
    if (signalName == @symbol(SIGILL)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1601
	RETURN ( __MKSMALLINT(SIGILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1602
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1603
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1604
#ifdef SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1605
    if (signalName == @symbol(SIGINT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1606
	RETURN ( __MKSMALLINT(SIGINT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1607
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1608
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1609
#ifdef SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1610
    if (signalName == @symbol(SIGIO)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1611
	RETURN ( __MKSMALLINT(SIGIO) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1612
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1613
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1614
#ifdef SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1615
    if (signalName == @symbol(SIGIOT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1616
	RETURN ( __MKSMALLINT(SIGIOT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1617
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1618
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1619
#ifdef SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1620
    if (signalName == @symbol(SIGKILL)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1621
	RETURN ( __MKSMALLINT(SIGKILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1622
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1623
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1624
#ifdef SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1625
    if (signalName == @symbol(SIGLOST)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1626
	RETURN ( __MKSMALLINT(SIGLOST) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1627
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1628
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1629
#ifdef SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1630
    if (signalName == @symbol(SIGMIGRATE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1631
	RETURN ( __MKSMALLINT(SIGMIGRATE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1632
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1633
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1634
#ifdef SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1635
    if (signalName == @symbol(SIGMSG)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1636
	RETURN ( __MKSMALLINT(SIGMSG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1637
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1638
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1639
#ifdef SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1640
    if (signalName == @symbol(SIGPIPE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1641
	RETURN ( __MKSMALLINT(SIGPIPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1642
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1643
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1644
#ifdef SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1645
    if (signalName == @symbol(SIGPOLL)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1646
	RETURN ( __MKSMALLINT(SIGPOLL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1647
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1648
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1649
#ifdef SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1650
    if (signalName == @symbol(SIGPRE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1651
	RETURN ( __MKSMALLINT(SIGPRE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1652
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1653
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1654
#ifdef SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1655
    if (signalName == @symbol(SIGPROF)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1656
	RETURN ( __MKSMALLINT(SIGPROF) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1657
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1658
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1659
#ifdef SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1660
    if (signalName == @symbol(SIGPWR)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1661
	RETURN ( __MKSMALLINT(SIGPWR) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1662
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1663
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1664
#ifdef SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1665
    if (signalName == @symbol(SIGQUIT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1666
	RETURN ( __MKSMALLINT(SIGQUIT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1667
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1668
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1669
#ifdef SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1670
    if (signalName == @symbol(SIGRETRACT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1671
	RETURN ( __MKSMALLINT(SIGRETRACT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1672
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1673
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1674
#ifdef SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1675
    if (signalName == @symbol(SIGSAK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1676
	RETURN ( __MKSMALLINT(SIGSAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1677
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1678
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1679
#ifdef SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1680
    if (signalName == @symbol(SIGSEGV)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1681
	RETURN ( __MKSMALLINT(SIGSEGV) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1682
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1683
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1684
#ifdef SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1685
    if (signalName == @symbol(SIGSOUND)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1686
	RETURN ( __MKSMALLINT(SIGSOUND) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1687
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1688
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1689
#ifdef SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1690
    if (signalName == @symbol(SIGSTOP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1691
	RETURN ( __MKSMALLINT(SIGSTOP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1692
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1693
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1694
#ifdef SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1695
    if (signalName == @symbol(SIGSYS)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1696
	RETURN ( __MKSMALLINT(SIGSYS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1697
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1698
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1699
#ifdef SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1700
    if (signalName == @symbol(SIGTERM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1701
	RETURN ( __MKSMALLINT(SIGTERM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1702
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1703
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1704
#ifdef SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1705
    if (signalName == @symbol(SIGTRAP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1706
	RETURN ( __MKSMALLINT(SIGTRAP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1707
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1708
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1709
#ifdef SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1710
    if (signalName == @symbol(SIGTSTP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1711
	RETURN ( __MKSMALLINT(SIGTSTP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1712
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1713
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1714
#ifdef SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1715
    if (signalName == @symbol(SIGTTIN)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1716
	RETURN ( __MKSMALLINT(SIGTTIN) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1717
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1718
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1719
#ifdef SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1720
    if (signalName == @symbol(SIGTTOU)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1721
	RETURN ( __MKSMALLINT(SIGTTOU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1722
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1723
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1724
#ifdef SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1725
    if (signalName == @symbol(SIGURG)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1726
	RETURN ( __MKSMALLINT(SIGURG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1727
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1728
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1729
#ifdef SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1730
    if (signalName == @symbol(SIGUSR1)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1731
	RETURN ( __MKSMALLINT(SIGUSR1) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1732
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1733
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1734
#ifdef SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1735
    if (signalName == @symbol(SIGUSR2)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1736
	RETURN ( __MKSMALLINT(SIGUSR2) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1737
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1738
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1739
#ifdef SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1740
    if (signalName == @symbol(SIGVTALRM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1741
	RETURN ( __MKSMALLINT(SIGVTALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1742
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1743
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1744
#ifdef SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1745
    if (signalName == @symbol(SIGWINCH)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1746
	RETURN ( __MKSMALLINT(SIGWINCH) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1747
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1748
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1749
#ifdef SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1750
    if (signalName == @symbol(SIGXCPU)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1751
	RETURN ( __MKSMALLINT(SIGXCPU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1752
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1753
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1754
#ifdef SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1755
    if (signalName == @symbol(SIGXFSZ)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1756
	RETURN ( __MKSMALLINT(SIGXFSZ) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1757
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1758
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1759
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
    RETURN ( __MKSMALLINT(0) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
%}
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1762
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1763
     OperatingSystem signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1764
     OperatingSystem signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1765
     OperatingSystem signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1766
     OperatingSystem signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1767
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1768
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
!UnixOperatingSystem class methodsFor:'error messages'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
currentErrorNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
    "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
  1774
     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
  1775
     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
  1776
     request to the OS.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1777
     Use lastErrorNumber - currentErrorNumber is invalidated by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1778
     many, many internal calls."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1779
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1780
%{  /* NOCONTEXT */
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
     RETURN ( __MKSMALLINT(errno) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1783
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1784
     "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  1785
      OperatingSystem currentErrorNumber
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1786
     "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1787
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1788
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1789
errorHolderForNumber:errNr
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1790
    "return an osErrorHolder for the given error number (as returned by a system call)." 
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1791
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1792
    |sym typ holder|
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1793
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1794
%{
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1795
    /* claus:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1796
     * I made this primitive code, since errnos are not
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1797
     * standard across unixes
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1798
     */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1799
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1800
    typ = @symbol(defaultOsErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1801
    sym = @symbol(ERROR_OTHER);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1802
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1803
    if (__isSmallInteger(errNr)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1804
	switch ( __intVal(errNr)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1805
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1806
	     * POSIX errnos - these should be defined
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1807
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1808
#ifdef EPERM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1809
	    case EPERM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1810
		sym = @symbol(EPERM);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1811
		typ = @symbol(noPermissionsSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1812
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1813
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1814
#ifdef ENOENT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1815
	    case ENOENT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1816
		sym = @symbol(ENOENT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1817
		typ = @symbol(nonexistentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1818
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1819
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1820
#ifdef ESRCH
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1821
	    case ESRCH:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1822
		sym = @symbol(ESRCH);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1823
		typ = @symbol(unavailableReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1824
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1825
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1826
#ifdef EINTR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1827
	    case EINTR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1828
		sym = @symbol(EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1829
		typ = @symbol(transientErrorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1830
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1831
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1832
#ifdef EIO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1833
	    case EIO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1834
		sym = @symbol(EIO);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1835
		typ = @symbol(transferFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1836
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1837
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1838
#ifdef ENXIO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1839
	    case ENXIO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1840
		sym = @symbol(ENXIO);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1841
		typ = @symbol(unavailableReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1842
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1843
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1844
#ifdef E2BIG
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1845
	    case E2BIG:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1846
		sym = @symbol(E2BIG);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1847
		typ = @symbol(invalidArgumentsSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1848
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1849
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1850
#ifdef ENOEXEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1851
	    case ENOEXEC:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1852
		sym = @symbol(ENOEXEC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1853
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1854
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1855
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1856
#ifdef EBADF
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1857
	    case EBADF:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1858
		sym = @symbol(EBADF);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1859
		typ = @symbol(badAccessorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1860
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1861
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1862
#ifdef ECHILD
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1863
	    case ECHILD:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1864
		sym = @symbol(ECHILD);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1865
		typ = @symbol(informationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1866
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1867
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1868
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1869
	    case EAGAIN:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1870
		sym = @symbol(EAGAIN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1871
		typ = @symbol(notReadySignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1872
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1873
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1874
#ifdef ENOMEM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1875
	    case ENOMEM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1876
		sym = @symbol(ENOMEM);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1877
		typ = @symbol(noMemorySignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1878
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1879
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1880
#ifdef EACCES
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1881
	    case EACCES:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1882
		sym = @symbol(EACCES);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1883
		typ = @symbol(noPermissionsSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1884
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1885
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1886
#ifdef EFAULT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1887
	    case EFAULT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1888
		sym = @symbol(EFAULT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1889
		typ = @symbol(invalidArgumentsSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1890
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1891
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1892
#ifdef EBUSY
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1893
	    case EBUSY:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1894
		sym = @symbol(EBUSY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1895
		typ = @symbol(unavailableReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1896
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1897
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1898
#ifdef EEXIST
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1899
	    case EEXIST:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1900
		sym = @symbol(EEXIST);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1901
		typ = @symbol(existingReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1902
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1903
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1904
#ifdef EXDEV
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1905
	    case EXDEV:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1906
		sym = @symbol(EXDEV);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1907
		typ = @symbol(inappropriateReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1908
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1909
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1910
#ifdef ENODEV
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1911
	    case ENODEV:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1912
		sym = @symbol(ENODEV);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1913
		typ = @symbol(inaccessibleSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1914
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1915
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1916
#ifdef ENOTDIR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1917
	    case ENOTDIR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1918
		sym = @symbol(ENOTDIR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1919
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1920
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1921
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1922
#ifdef EISDIR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1923
	    case EISDIR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1924
		sym = @symbol(EISDIR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1925
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1926
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1927
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1928
#ifdef EINVAL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1929
	    case EINVAL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1930
		sym = @symbol(EINVAL);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1931
		typ = @symbol(invalidArgumentsSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1932
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1933
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1934
#ifdef ENFILE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1935
	    case ENFILE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1936
		sym = @symbol(ENFILE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1937
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1938
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1939
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1940
#ifdef EMFILE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1941
	    case EMFILE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1942
		sym = @symbol(EMFILE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1943
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1944
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1945
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1946
#ifdef ENOTTY
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1947
	    case ENOTTY:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1948
		sym = @symbol(ENOTTY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1949
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1950
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1951
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1952
#ifdef EFBIG
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1953
	    case EFBIG:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1954
		sym = @symbol(EFBIG);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1955
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1956
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1957
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1958
#ifdef ENOSPC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1959
	    case ENOSPC:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1960
		sym = @symbol(ENOSPC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1961
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1962
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1963
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1964
#ifdef ESPIPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1965
	    case ESPIPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1966
		sym = @symbol(ESPIPE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1967
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1968
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1969
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1970
#ifdef EROFS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1971
	    case EROFS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1972
		sym = @symbol(EROFS);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1973
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1974
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1975
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1976
#ifdef EMLINK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1977
	    case EMLINK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1978
		sym = @symbol(EMLINK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1979
		typ = @symbol(rangeErrorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1980
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1981
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1982
#ifdef EPIPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1983
	    case EPIPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1984
		sym = @symbol(EPIPE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1985
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1986
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1987
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1988
#ifdef EDOM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1989
	    case EDOM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1990
		sym = @symbol(EDOM);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1991
		typ = @symbol(rangeErrorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1992
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1993
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1994
#ifdef ERANGE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1995
	    case ERANGE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1996
		sym = @symbol(ERANGE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1997
		typ = @symbol(rangeErrorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1998
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1999
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2000
#ifdef EDEADLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2001
# if EDEADLK != EWOULDBLOCK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2002
	    case EDEADLK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2003
		sym = @symbol(EDEADLK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2004
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
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
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2008
#ifdef ENAMETOOLONG
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2009
	    case ENAMETOOLONG:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2010
		sym = @symbol(ENAMETOOLONG);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2011
		typ = @symbol(rangeErrorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2012
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2013
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2014
#ifdef ENOLCK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2015
	    case ENOLCK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2016
		sym = @symbol(ENOLCK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2017
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2018
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2019
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2020
#ifdef ENOSYS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2021
	    case ENOSYS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2022
		sym = @symbol(ENOSYS);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2023
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
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
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2027
	    case ENOTEMPTY:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2028
		sym = @symbol(ENOTEMPTY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2029
		typ = @symbol(inappropriateReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2030
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2031
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2032
#ifdef EILSEQ
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2033
	    case EILSEQ:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2034
		sym = @symbol(EILSEQ);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2035
		typ = @symbol(transferFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2036
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2037
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2038
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2039
	     * XPG3 errnos - defined on most systems
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2040
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2041
#ifdef ENOTBLK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2042
	    case ENOTBLK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2043
		sym = @symbol(ENOTBLK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2044
		typ = @symbol(inappropriateReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2045
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2046
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2047
#ifdef ETXTBSY
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2048
	    case ETXTBSY:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2049
		sym = @symbol(ETXTBSY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2050
		typ = @symbol(inaccessibleSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2051
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2052
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2053
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2054
	     * some others
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2055
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2056
#ifdef EWOULDBLOCK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2057
	    case EWOULDBLOCK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2058
		sym = @symbol(EWOULDBLOCK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2059
		typ = @symbol(notReadySignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2060
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2061
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2062
#ifdef ENOMSG
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2063
	    case ENOMSG:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2064
		sym = @symbol(ENOMSG);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2065
		typ = @symbol(noDataSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2066
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2067
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2068
#ifdef ELOOP
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2069
	    case ELOOP:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2070
		sym = @symbol(ELOOP);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2071
		typ = @symbol(rangeErrorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2072
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2073
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2074
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2075
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2076
	     * some stream errors
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2077
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2078
#ifdef ETIME
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2079
	    case ETIME:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2080
		sym = @symbol(ETIME);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2081
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2082
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2083
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2084
#ifdef ENOSR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2085
	    case ENOSR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2086
		sym = @symbol(ENOSR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2087
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2088
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2089
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2090
#ifdef ENOSTR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2091
	    case ENOSTR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2092
		sym = @symbol(ENOSTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2093
		typ = @symbol(inappropriateReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2094
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2095
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2096
#ifdef ECOMM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2097
	    case ECOMM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2098
		sym = @symbol(ECOMM);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2099
		typ = @symbol(transferFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2100
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2101
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2102
#ifdef EPROTO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2103
	    case EPROTO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2104
		sym = @symbol(EPROTO);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2105
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2106
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2107
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2108
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2109
	     * nfs errors
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2110
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2111
#ifdef ESTALE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2112
	    case ESTALE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2113
		sym = @symbol(ESTALE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2114
		typ = @symbol(unavailableReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2115
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2116
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2117
#ifdef EREMOTE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2118
	    case EREMOTE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2119
		sym = @symbol(EREMOTE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2120
		typ = @symbol(rangeErrorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2121
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2122
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2123
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2124
	     * some networking errors
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2125
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2126
#ifdef EINPROGRESS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2127
	    case EINPROGRESS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2128
		sym = @symbol(EINPROGRESS);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2129
		typ = @symbol(operationStartedSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2130
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2131
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2132
#ifdef EALREADY
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2133
	    case EALREADY:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2134
		sym = @symbol(EALREADY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2135
		typ = @symbol(operationStartedSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2136
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2137
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2138
#ifdef ENOTSOCK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2139
	    case ENOTSOCK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2140
		sym = @symbol(ENOTSOCK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2141
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2142
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2143
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2144
#ifdef EDESTADDRREQ
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2145
	    case EDESTADDRREQ:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2146
		sym = @symbol(EDESTADDRREQ);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2147
		typ = @symbol(underspecifiedSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2148
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2149
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2150
#ifdef EMSGSIZE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2151
	    case EMSGSIZE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2152
		sym = @symbol(EMSGSIZE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2153
		typ = @symbol(rangeErrorSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2154
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2155
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2156
#ifdef EPROTOTYPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2157
	    case EPROTOTYPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2158
		sym = @symbol(EPROTOTYPE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2159
		typ = @symbol(wrongSubtypeForOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2160
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2161
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2162
#ifdef ENOPROTOOPT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2163
	    case ENOPROTOOPT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2164
		sym = @symbol(ENOPROTOOPT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2165
		typ = @symbol(unsupportedOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2166
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2167
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2168
#ifdef EPROTONOSUPPORT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2169
	    case EPROTONOSUPPORT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2170
		sym = @symbol(EPROTONOSUPPORT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2171
		typ = @symbol(unsupportedOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2172
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2173
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2174
#ifdef ESOCKTNOSUPPORT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2175
	    case ESOCKTNOSUPPORT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2176
		sym = @symbol(ESOCKTNOSUPPORT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2177
		typ = @symbol(unsupportedOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2178
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2179
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2180
#ifdef EOPNOTSUPP
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2181
	    case EOPNOTSUPP:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2182
		sym = @symbol(EOPNOTSUPP);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2183
		typ = @symbol(inappropriateOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2184
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2185
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2186
#ifdef EPFNOSUPPORT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2187
	    case EPFNOSUPPORT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2188
		sym = @symbol(EPFNOSUPPORT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2189
		typ = @symbol(unsupportedOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2190
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2191
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2192
#ifdef EAFNOSUPPORT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2193
	    case EAFNOSUPPORT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2194
		sym = @symbol(EAFNOSUPPORT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2195
		typ = @symbol(unsupportedOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2196
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2197
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2198
#ifdef EADDRINUSE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2199
	    case EADDRINUSE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2200
		sym = @symbol(EADDRINUSE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2201
		typ = @symbol(existingReferentSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2202
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2203
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2204
#ifdef EADDRNOTAVAIL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2205
	    case EADDRNOTAVAIL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2206
		sym = @symbol(EADDRNOTAVAIL);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2207
		typ = @symbol(noPermissionsSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2208
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2209
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2210
#ifdef ETIMEDOUT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2211
	    case ETIMEDOUT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2212
		sym = @symbol(ETIMEDOUT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2213
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2214
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2215
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2216
#ifdef ECONNREFUSED
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2217
	    case ECONNREFUSED:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2218
		sym = @symbol(ECONNREFUSED);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2219
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2220
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2221
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2222
#ifdef ENETDOWN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2223
	    case ENETDOWN:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2224
		sym = @symbol(ENETDOWN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2225
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2226
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2227
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2228
#ifdef ENETUNREACH
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2229
	    case ENETUNREACH:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2230
		sym = @symbol(ENETUNREACH);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2231
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2232
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2233
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2234
#ifdef ENETRESET
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2235
	    case ENETRESET:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2236
		sym = @symbol(ENETRESET);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2237
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2238
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2239
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2240
#ifdef ECONNABORTED
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2241
	    case ECONNABORTED:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2242
		sym = @symbol(ECONNABORTED);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2243
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2244
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2245
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2246
#ifdef ECONNRESET
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2247
	    case ECONNRESET:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2248
		sym = @symbol(ECONNRESET);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2249
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2250
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2251
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2252
#ifdef EISCONN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2253
	    case EISCONN:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2254
		sym = @symbol(EISCONN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2255
		typ = @symbol(unpreparedOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2256
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2257
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2258
#ifdef ENOTCONN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2259
	    case ENOTCONN:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2260
		sym = @symbol(ENOTCONN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2261
		typ = @symbol(unpreparedOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2262
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2263
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2264
#ifdef ESHUTDOWN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2265
	    case ESHUTDOWN:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2266
		sym = @symbol(ESHUTDOWN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2267
		typ = @symbol(unpreparedOperationSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2268
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2269
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2270
#ifdef EHOSTDOWN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2271
	    case EHOSTDOWN:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2272
		sym = @symbol(EHOSTDOWN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2273
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2274
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2275
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2276
#ifdef EHOSTUNREACH
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2277
	    case EHOSTUNREACH:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2278
		sym = @symbol(EHOSTUNREACH);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2279
		typ = @symbol(peerFaultSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2280
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2281
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2282
#ifdef EDQUOT
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2283
	    case EDQUOT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2284
		sym = @symbol(EDQUOT);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2285
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2286
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2287
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2288
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2289
#ifdef ENOMEDIUM
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2290
	    case ENOMEDIUM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2291
		sym = @symbol(ENOMEDIUM);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2292
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2293
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2294
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2295
#ifdef EMEDIUMTYPE
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2296
	    case EMEDIUMTYPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2297
		sym = @symbol(EMEDIUMTYPE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2298
		typ = @symbol(noResourcesSignal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2299
		break;
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
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2302
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2303
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2304
	}
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2305
    }
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2306
%}.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2307
    holder := OSErrorHolder new.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2308
    holder errorSymbol:sym errorCategory:typ.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2309
    ^ holder
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2310
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2311
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2312
     OperatingSystem errorHolderForNumber:4           
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2313
     self errorHolderForNumber:(self errorNumberFor:#EPERM)   
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2314
     self errorHolderForNumber:(self errorNumberFor:#EIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2315
     self errorHolderForNumber:(self errorNumberFor:#ENXIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2316
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2317
!
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2318
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2319
errorNumberFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2320
    "given a symbolic error, return the numeric;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2322
     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
  2323
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2324
%{   /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2325
    OBJ sym = aSymbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2326
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2327
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2328
     * POSIX errnos - these should be defined
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2329
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2330
#ifdef EPERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2331
    if (sym == @symbol(EPERM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2332
	RETURN ( __MKSMALLINT(EPERM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2334
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
#ifdef ENOENT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2337
    if (sym == @symbol(ENOENT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2338
	RETURN ( __MKSMALLINT(ENOENT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2339
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2340
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2341
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2342
#ifdef ESRCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2343
    if (sym == @symbol(ESRCH)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2344
	RETURN ( __MKSMALLINT(ESRCH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2345
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2346
#endif
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
#ifdef EINTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2349
    if (sym == @symbol(EINTR)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2350
	RETURN ( __MKSMALLINT(EINTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2351
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2352
#endif
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
#ifdef EIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2355
    if (sym == @symbol(EIO)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2356
	RETURN ( __MKSMALLINT(EIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2357
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2358
#endif
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
#ifdef ENXIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2361
    if (sym == @symbol(ENXIO)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2362
	RETURN ( __MKSMALLINT(ENXIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2363
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2364
#endif
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
#ifdef E2BIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2367
    if (sym == @symbol(E2BIG)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2368
	RETURN ( __MKSMALLINT(E2BIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2369
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2370
#endif
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
#ifdef ENOEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2373
    if (sym == @symbol(ENOEXEC)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2374
	RETURN ( __MKSMALLINT(ENOEXEC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2375
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2376
#endif
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
#ifdef EBADF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2379
    if (sym == @symbol(EBADF)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2380
	RETURN ( __MKSMALLINT(EBADF) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2381
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2382
#endif
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
#ifdef ECHILD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2385
    if (sym == @symbol(ECHILD)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2386
	RETURN ( __MKSMALLINT(ECHILD) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2387
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2388
#endif
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
#if defined(EAGAIN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
    if (sym == @symbol(EAGAIN)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2392
	RETURN ( __MKSMALLINT(EAGAIN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2393
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2394
#endif
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
#ifdef ENOMEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2397
    if (sym == @symbol(ENOMEM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2398
	RETURN ( __MKSMALLINT(ENOMEM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2399
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2400
#endif
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
#ifdef EACCES
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2403
    if (sym == @symbol(EACCES)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2404
	RETURN ( __MKSMALLINT(EACCES) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2405
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2406
#endif
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
#ifdef EFAULT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2409
    if (sym == @symbol(EFAULT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2410
	RETURN ( __MKSMALLINT(EFAULT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2411
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2412
#endif
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
#ifdef EBUSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2415
    if (sym == @symbol(EBUSY)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2416
	RETURN ( __MKSMALLINT(EBUSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2417
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2418
#endif
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
#ifdef EXDEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2421
    if (sym == @symbol(EXDEV)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2422
	RETURN ( __MKSMALLINT(EXDEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2423
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2424
#endif
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
#ifdef ENODEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2427
    if (sym == @symbol(ENODEV)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2428
	RETURN ( __MKSMALLINT(ENODEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2429
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2430
#endif
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
#ifdef ENOTDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2433
    if (sym == @symbol(ENOTDIR)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2434
	RETURN ( __MKSMALLINT(ENOTDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2435
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2436
#endif
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
#ifdef EISDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2439
    if (sym == @symbol(EISDIR)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2440
	RETURN ( __MKSMALLINT(EISDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2441
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2442
#endif
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
#ifdef EINVAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2445
    if (sym == @symbol(EINVAL)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2446
	RETURN ( __MKSMALLINT(EINVAL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2447
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2448
#endif
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
#ifdef ENFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2451
    if (sym == @symbol(ENFILE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2452
	RETURN ( __MKSMALLINT(ENFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2453
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2454
#endif
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
#ifdef EMFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2457
    if (sym == @symbol(EMFILE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2458
	RETURN ( __MKSMALLINT(EMFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2459
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2460
#endif
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
#ifdef ENOTTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2463
    if (sym == @symbol(ENOTTY)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2464
	RETURN ( __MKSMALLINT(ENOTTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2465
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2466
#endif
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
#ifdef EFBIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2469
    if (sym == @symbol(EFBIG)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2470
	RETURN ( __MKSMALLINT(EFBIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2471
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2472
#endif
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
#ifdef ENOSPC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
    if (sym == @symbol(ENOSPC)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2476
	RETURN ( __MKSMALLINT(ENOSPC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2477
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2478
#endif
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
#ifdef ESPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2481
    if (sym == @symbol(ESPIPE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2482
	RETURN ( __MKSMALLINT(ESPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2483
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2484
#endif
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
#ifdef EROFS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2487
    if (sym == @symbol(EROFS)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2488
	RETURN ( __MKSMALLINT(EROFS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2489
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2490
#endif
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
#ifdef EMLINK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2493
    if (sym == @symbol(EMLINK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2494
	RETURN ( __MKSMALLINT(EMLINK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2495
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2496
#endif
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
#ifdef EPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2499
    if (sym == @symbol(EPIPE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2500
	RETURN ( __MKSMALLINT(EPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2502
#endif
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
#ifdef EDOM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2505
    if (sym == @symbol(EDOM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2506
	RETURN ( __MKSMALLINT(EDOM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2507
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2508
#endif
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
#ifdef ERANGE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2511
    if (sym == @symbol(ERANGE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2512
	RETURN ( __MKSMALLINT(ERANGE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2513
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2514
#endif
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
#ifdef EDEADLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2517
    if (sym == @symbol(EDEADLK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2518
	RETURN ( __MKSMALLINT(EDEADLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2519
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2520
#endif
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
#ifdef ENAMETOOLONG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2523
    if (sym == @symbol(ENAMETOOLONG)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2524
	RETURN ( __MKSMALLINT(ENAMETOOLONG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2525
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2526
#endif
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
#ifdef ENOLCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2529
    if (sym == @symbol(ENOLCK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2530
	RETURN ( __MKSMALLINT(ENOLCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2531
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2532
#endif
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
#ifdef ENOSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2535
    if (sym == @symbol(ENOSYS)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2536
	RETURN ( __MKSMALLINT(ENOSYS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2537
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2538
#endif
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
#ifdef ENOTEMPTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2541
    if (sym == @symbol(ENOTEMPTY)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2542
	RETURN ( __MKSMALLINT(ENOTEMPTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2543
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2544
#endif
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
#ifdef EEXIST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2547
    if (sym == @symbol(EEXIST)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2548
	RETURN ( __MKSMALLINT(EEXIST) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2549
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2550
#endif
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
#ifdef EILSEQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2553
    if (sym == @symbol(EILSEQ)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2554
	RETURN ( __MKSMALLINT(EILSEQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2555
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2556
#endif
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2559
     * XPG3 errnos - defined on most systems
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2560
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2561
#ifdef ENOTBLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2562
    if (sym == @symbol(ENOTBLK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2563
	RETURN ( __MKSMALLINT(ENOTBLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2564
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2565
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2566
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2567
#ifdef ETXTBSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2568
    if (sym == @symbol(ETXTBSY)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2569
	RETURN ( __MKSMALLINT(ETXTBSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2570
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2571
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2572
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2573
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2574
     * some others
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
#ifdef EWOULDBLOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2577
    if (sym == @symbol(EWOULDBLOCK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2578
	RETURN ( __MKSMALLINT(EWOULDBLOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2579
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2580
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2581
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2582
#ifdef ENOMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2583
    if (sym == @symbol(ENOMSG)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2584
	RETURN ( __MKSMALLINT(ENOMSG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2585
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2586
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2587
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
#ifdef ELOOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2589
    if (sym == @symbol(ELOOP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2590
	RETURN ( __MKSMALLINT(ELOOP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
#endif
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2595
     * some stream errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2596
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2597
#ifdef ETIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2598
    if (sym == @symbol(ETIME)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2599
	RETURN ( __MKSMALLINT(ETIME) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2600
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2601
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2602
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2603
#ifdef ENOSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2604
    if (sym == @symbol(ENOSR)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2605
	RETURN ( __MKSMALLINT(ENOSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2606
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2607
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2608
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
#ifdef ENOSTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2610
    if (sym == @symbol(ENOSTR)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2611
	RETURN ( __MKSMALLINT(ENOSTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2612
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2613
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2614
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2615
#ifdef ECOMM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2616
    if (sym == @symbol(ECOMM)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2617
	RETURN ( __MKSMALLINT(ECOMM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2618
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2619
#endif
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
#ifdef EPROTO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2622
    if (sym == @symbol(EPROTO)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2623
	RETURN ( __MKSMALLINT(EPROTO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2624
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2625
#endif
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2628
     * nfs errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2629
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2630
#ifdef ESTALE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2631
    if (sym == @symbol(ESTALE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2632
	RETURN ( __MKSMALLINT(ESTALE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2633
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2634
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2635
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2636
#ifdef EREMOTE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2637
    if (sym == @symbol(EREMOTE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2638
	RETURN ( __MKSMALLINT(EREMOTE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2639
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2640
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2641
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2642
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2643
     * some networking errors
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
#ifdef EINPROGRESS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2646
    if (sym == @symbol(EINPROGRESS)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2647
	RETURN ( __MKSMALLINT(EINPROGRESS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2648
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2649
#endif
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
#ifdef EALREADY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2652
    if (sym == @symbol(EALREADY)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2653
	RETURN ( __MKSMALLINT(EALREADY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2654
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2655
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2656
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2657
#ifdef ENOTSOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2658
    if (sym == @symbol(ENOTSOCK)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2659
	RETURN ( __MKSMALLINT(ENOTSOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2660
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2661
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2662
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2663
#ifdef EDESTADDRREQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2664
    if (sym == @symbol(EDESTADDRREQ)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2665
	RETURN ( __MKSMALLINT(EDESTADDRREQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2666
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2667
#endif
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
#ifdef EMSGSIZE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2670
    if (sym == @symbol(EMSGSIZE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2671
	RETURN ( __MKSMALLINT(EMSGSIZE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2672
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2673
#endif
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
#ifdef EPROTOTYPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2676
    if (sym == @symbol(EPROTOTYPE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2677
	RETURN ( __MKSMALLINT(EPROTOTYPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2679
#endif
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
#ifdef ENOPROTOOPT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2682
    if (sym == @symbol(ENOPROTOOPT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2683
	RETURN ( __MKSMALLINT(ENOPROTOOPT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2684
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2685
#endif
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
#ifdef EPROTONOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2688
    if (sym == @symbol(EPROTONOSUPPORT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2689
	RETURN ( __MKSMALLINT(EPROTONOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2690
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2691
#endif
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
#ifdef ESOCKTNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2694
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2695
	RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2697
#endif
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
#ifdef EOPNOTSUPP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2700
    if (sym == @symbol(EOPNOTSUPP)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2701
	RETURN ( __MKSMALLINT(EOPNOTSUPP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2703
#endif
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
#ifdef EPFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2706
    if (sym == @symbol(EPFNOSUPPORT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2707
	RETURN ( __MKSMALLINT(EPFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2708
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2709
#endif
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
#ifdef EAFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2712
    if (sym == @symbol(EAFNOSUPPORT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2713
	RETURN ( __MKSMALLINT(EAFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2715
#endif
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
#ifdef EADDRINUSE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2718
    if (sym == @symbol(EADDRINUSE)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2719
	RETURN ( __MKSMALLINT(EADDRINUSE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2720
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2721
#endif
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
#ifdef EADDRNOTAVAIL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2724
    if (sym == @symbol(EADDRNOTAVAIL)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2725
	RETURN ( __MKSMALLINT(EADDRNOTAVAIL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2726
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2727
#endif
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
#ifdef ETIMEDOUT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2730
    if (sym == @symbol(ETIMEDOUT)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2731
	RETURN ( __MKSMALLINT(ETIMEDOUT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2732
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2733
#endif
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
#ifdef ECONNREFUSED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2736
    if (sym == @symbol(ECONNREFUSED)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2737
	RETURN ( __MKSMALLINT(ECONNREFUSED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2738
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2739
#endif
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
#ifdef ENETDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2742
    if (sym == @symbol(ENETDOWN)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2743
	RETURN ( __MKSMALLINT(ENETDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2744
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2745
#endif
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
#ifdef ENETUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2748
    if (sym == @symbol(ENETUNREACH)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2749
	RETURN ( __MKSMALLINT(ENETUNREACH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2751
#endif
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
#ifdef ENETRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2754
    if (sym == @symbol(ENETRESET)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2755
	RETURN ( __MKSMALLINT(ENETRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2757
#endif
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
#ifdef ECONNABORTED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2760
    if (sym == @symbol(ECONNABORTED)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2761
	RETURN ( __MKSMALLINT(ECONNABORTED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2762
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2763
#endif
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
#ifdef ECONNRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2766
    if (sym == @symbol(ECONNRESET)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2767
	RETURN ( __MKSMALLINT(ECONNRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2768
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2769
#endif
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
#ifdef EISCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2772
    if (sym == @symbol(EISCONN)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2773
	RETURN ( __MKSMALLINT(EISCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2774
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2775
#endif
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
#ifdef ENOTCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2778
    if (sym == @symbol(ENOTCONN)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2779
	RETURN ( __MKSMALLINT(ENOTCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2780
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2781
#endif
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
#ifdef ESHUTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
    if (sym == @symbol(ESHUTDOWN)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2785
	RETURN ( __MKSMALLINT(ESHUTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2787
#endif
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
#ifdef EHOSTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2790
    if (sym == @symbol(EHOSTDOWN)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2791
	RETURN ( __MKSMALLINT(EHOSTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2793
#endif
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
#ifdef EHOSTUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2796
    if (sym == @symbol(EHOSTUNREACH)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2797
	RETURN ( __MKSMALLINT(EHOSTUNREACH) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2798
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2799
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2800
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2801
#ifdef EREMOTEIO
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2802
    if (sym == @symbol(EREMOTEIO)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2803
	RETURN ( __MKSMALLINT(EREMOTEIO) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2804
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2805
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2806
#ifdef EDQUOT
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2807
    if (sym == @symbol(EDQUOT)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2808
	RETURN ( __MKSMALLINT(EDQUOT) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2809
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2810
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2811
#ifdef ENOMEDIUM
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2812
    if (sym == @symbol(ENOMEDIUM)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2813
	RETURN ( __MKSMALLINT(ENOMEDIUM) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2814
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2815
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2816
#ifdef EMEDIUMTYPE
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2817
    if (sym == @symbol(EMEDIUMTYPE)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2818
	RETURN ( __MKSMALLINT(EMEDIUMTYPE) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2819
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2820
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2821
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2823
    ^ -1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2825
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2826
!UnixOperatingSystem class methodsFor:'executing OS commands-implementation'!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2827
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2828
exec:aCommandPath withArguments:argColl environment:environmentDictionary
7170
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  2829
    fileDescriptors:fdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  2830
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2831
    "Internal lowLevel entry for combined fork & exec;
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2832
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2833
     If fork is false (chain a command):
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2834
	 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
  2835
	 arguments in argArray (no arguments, if nil).
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2836
	 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
  2837
	 If not successful, it does return.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2838
	 Normal use is with forkForCommand.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2839
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2840
     If fork is true (subprocess command execution):
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2841
	fork a child to do the above.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2842
	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
  2843
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7072
diff changeset
  2844
     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
  2845
	fdArray[1] = 15 -> use fd 15 as stdin.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2846
	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
  2847
	will be closed for the child.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2848
	fdArray[1] == StdIn for child
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2849
	fdArray[2] == StdOut for child
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2850
	fdArray[3] == StdErr for child
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2851
	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
  2852
	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
  2853
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2854
     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
  2855
	The processgroup will be equal to id.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2856
	newPgrp is not used on WIN32 and VMS systems.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2857
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2858
     environmentDictionary specifies environment variables which are passed differently from
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2859
     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
  2860
     key-value pairs for changed/added environment variables.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2861
     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
  2862
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2863
     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
  2864
	    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
  2865
	    accesses to ST/X memory from the vforked-child.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2866
	    The code below only does read accesses."
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2867
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2868
    |envArray argArray fdArray dirName cnt|
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2869
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2870
    environmentDictionary size ~~ 0 ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2871
	envArray := Array new:environmentDictionary size.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2872
	cnt := 1.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2873
	environmentDictionary keysAndValuesDo:[:key :val |
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2874
	    val isNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2875
		envArray at:cnt put:(key, '=')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2876
	    ] ifFalse:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2877
		envArray at:cnt put:(key, '=', val)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2878
	    ].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2879
	    cnt := cnt + 1.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2880
	].
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2881
    ].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2882
    argColl notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2883
	argArray := argColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2884
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2885
    fdColl notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2886
	fdArray := fdColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2887
    ].
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2888
    aDirectory notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2889
	dirName := aDirectory asFilename name
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2890
    ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2891
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2892
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2893
    char **argv;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2894
    int nargs, i, id;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2895
    OBJ arg;
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2896
    extern char **environ;
3571
9090dc66a427 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
  2897
    char **_env, **_nEnv;
3801
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2898
#ifndef __isArrayLike
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2899
# define __isArrayLike __isArray
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2900
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2901
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2902
    if (__isString(aCommandPath) && 
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2903
	((argArray == nil) || __isArrayLike(argArray)) &&
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2904
	((fdArray == nil) || __isArrayLike(fdArray))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2905
    ) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2906
	nargs = argArray == nil ? 0 : __arraySize(argArray);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2907
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2908
	if (argv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2909
	    int nOldEnv, nNewEnv;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2910
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2911
	    for (i=0; i < nargs; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2912
		arg = __ArrayInstPtr(argArray)->a_element[i];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2913
		if (__isString(arg)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2914
		    argv[i] = (char *) __stringVal(arg);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2915
		} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2916
		    argv[i] = "";
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2917
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2918
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2919
	    argv[i] = NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2920
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2921
	    /*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2922
	     * number of new items in environment ..       
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2923
	     */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2924
	    nNewEnv = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2925
	    if ((envArray != nil) && __isArrayLike(envArray)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2926
		nNewEnv = __arraySize(envArray);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2927
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2928
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2929
	    if (nNewEnv == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2930
		_nEnv = environ;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2931
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2932
		_env = environ;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2933
		/* 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2934
		 * get size of environment
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2935
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2936
		nOldEnv = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2937
		if (_env) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2938
		    while (*_env) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2939
			nOldEnv++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2940
			_env++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2941
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2942
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2943
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2944
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2945
		 * generate a new environment
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2946
		 * I have not found a spec which defines if
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2947
		 * items at the end overwrite previous definitions,
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2948
		 * or if the first encountered definition is valid.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2949
		 * 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
  2950
		 * 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
  2951
		 * 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
  2952
		 * getenv() searches for the first entry.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2953
		 * But maybe someone creates a Dictionary from the environment. 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2954
		 * 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
  2955
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2956
		_nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2957
		if (_nEnv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2958
		    char **eO, **eN;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2959
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2960
		    eN = _nEnv;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2961
		    if (nNewEnv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2962
			/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2963
			 * add new items at the front ...
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2964
			 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2965
			int i;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2966
			OBJ *t;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2967
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2968
			for (i=0, t = __arrayVal(envArray); 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2969
			     i < __arraySize(envArray); 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2970
			     i++, t++) {
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
			    if (__isString(*t)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2973
				*eN++ = (char *)__stringVal(*t);
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
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2976
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2977
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2978
		    if (nOldEnv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2979
			/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2980
			 * append old environment 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2981
			 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2982
			for (eO = environ; *eO; *eN++ = *eO++) 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2983
			    continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2984
		    }
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
		    if (nNewEnv) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2987
			/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2988
			 * append new items again at the end
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
			for (eO = _nEnv, i=0; i<nNewEnv; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2991
			    *eN++ = *eO++;
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
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2994
		    *eN = NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2995
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2996
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2997
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2998
	    if (doFork == true) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  2999
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3000
		 * fork a subprocess.
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
		int nfd;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3003
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3004
		nfd = fdArray == nil ? 0 : __arraySize(fdArray);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3005
		id = FORK ();
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3006
		if (id == 0) {
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
		    ** In child.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3009
		    ** first: dup filedescriptors.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3010
		    */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3011
		    for (i = 0; i < nfd; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3012
			OBJ fd;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3013
			int rslt;
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
			fd = __arrayVal(fdArray)[i];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3016
			if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3017
			    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3018
				rslt = dup2(__intVal(fd), i);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3019
			    } while ((rslt < 0) && (errno == EINTR));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3020
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3021
		    }
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
		    ** Second: close descriptors
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3024
		    **         marked as unwanted
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3025
		    ** (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
  3026
		    **  higher fd numbers)
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
		    for (i = 0; i < nfd; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3029
			if (__arrayVal(fdArray)[i] == nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3030
			    close(i);
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
		    }
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
		    /*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3035
		    ** third: close all filedescriptors larger
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3036
		    ** then the explicitely closed or duped
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3037
		    ** filedescriptors
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3038
		    */
7072
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3039
#ifndef OPEN_MAX
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3040
# define OPEN_MAX       256
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3041
#endif
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3042
		    for ( ;i < OPEN_MAX; i++) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3043
			close(i);
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
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3046
		    if (newPgrp == true) {
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3047
#ifndef NEXT
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3048
			setsid();
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3049
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3050
#if defined(TIOCSCTTY)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3051
			ioctl(0, TIOCSCTTY, 0) ;
3561
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3052
#endif
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3053
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3054
#if defined(TIOCSPGRP)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3055
			{
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3056
			    int pgrp = getpid();
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
			    ioctl(0, TIOCSPGRP, (char *)&pgrp);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3059
			}
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3060
#endif
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3061
#if defined(_POSIX_JOB_CONTROL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3062
			(void) setpgid(0, 0);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3063
#else
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3064
# if defined(BSD) || defined(LINUX)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3065
			(void) setpgrp(0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3066
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3067
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3068
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3069
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3070
		    if (dirName != nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3071
			chdir(__stringVal(dirName));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3072
		    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3073
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3074
		    execve(__stringVal(aCommandPath), argv, _nEnv);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3075
		    /* reached if aCommandPathh cannot be executed */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3076
		    _exit(127);                 /* POSIX 2 compatible exit value */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3077
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3078
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3079
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3080
		 * no subprocess (i.e. transfer to another program)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3081
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3082
		if (dirName != nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3083
		    chdir(__stringVal(dirName));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3084
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3085
		execve(__stringVal(aCommandPath), argv, _nEnv);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3086
		/* 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3087
		 * reached if command-path cannot be executed
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3088
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3089
		id = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3090
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3091
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3092
	    if (nNewEnv && (_nEnv != NULL)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3093
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3094
		 * free new environment stuff
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3095
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3096
		free(_nEnv);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3097
	    }
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
	    free(argv);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3100
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3101
	    /*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3102
	     * In parent: succes or failure
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
	    if (id == -1) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3105
		RETURN (nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3106
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3107
		RETURN (__MKSMALLINT(id));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3108
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3109
	}
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3110
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3111
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3112
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3113
     path-argument not string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3114
     or argArray not an array/nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3115
     or malloc failed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3116
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3117
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3118
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3119
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3120
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3121
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3122
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3123
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3124
     id == 0 ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3125
	'I am the child'.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3126
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3127
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3128
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3129
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3130
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3131
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3132
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3133
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3134
     id == 0 ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3135
	'I am the child'.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3136
	OperatingSystem
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3137
	   exec:'/bin/sh'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3138
	   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
  3139
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3140
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
     id printNL.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
     (Delay forSeconds:3.5) wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
     'killing ...' printNL.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3144
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3145
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3147
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
    "fork a new (HEAVY-weight) unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
     Not supported with MSDOS & VMS systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3152
     Dont confuse this with Block>>fork, which creates 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3153
     lightweight smalltalk processes. This method will return
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
     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
  3155
     unix-process-id) to the parent (original) process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3157
     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
  3158
     #startProcess: and #executCommand: for higher level interfaces."
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
    int pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3162
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
    pid = fork();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
    RETURN ( __MKUINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3165
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3166
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3167
    "/ not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3168
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3169
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3170
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3172
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3173
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3174
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3175
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3176
     id == 0 ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3177
	'I am the child process' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3178
	OperatingSystem exit
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3179
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3180
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3181
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3182
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3183
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream 
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3184
    errorTo:anExternalErrStream auxFrom:anAuxiliaryStream 
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3185
    environment:anEvironmentDictionary inDirectory:dir
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3186
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3187
    "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
  3188
     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
  3189
     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
  3190
     '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
  3191
     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
  3192
     each may be nil.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3193
     Return the processId if successful, nil otherwise.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3194
     Use #monitorPid:action: for synchronization and exec status return,
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3195
     or #killProcess: to stop it."
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3196
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3197
    |nullStream in out err shellAndArgs rslt auxFd|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3198
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3199
    aCommandString isNil ifTrue:[^ nil].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3200
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3201
    (in := anExternalInStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3202
	nullStream := Filename nullDevice readWriteStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3203
	in := nullStream. 
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3204
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3205
    (out := anExternalOutStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3206
	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3207
	out := nullStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3208
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3209
    (err := anExternalErrStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3210
	err := out
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3211
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3212
    anAuxiliaryStream notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3213
	auxFd := anAuxiliaryStream fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3214
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3215
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3216
    shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3217
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3218
    rslt := self
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3219
	exec:(shellAndArgs at:1)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3220
	withArguments:(shellAndArgs at:2)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3221
	environment:anEvironmentDictionary
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3222
	fileDescriptors:(Array with:in fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3223
			       with:out fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3224
			       with:err fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3225
			       with:auxFd)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3226
	fork:true
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3227
	newPgrp:true "/ false
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3228
	inDirectory:dir.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3229
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3230
    nullStream notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3231
	nullStream close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3232
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3233
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3234
    ^ rslt
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3235
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3236
    "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
  3237
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3238
     OperatingSystem executeCommand:'ls -l > out'.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3239
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3240
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3241
    "non-blocking (lower prio threads continue):
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3242
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3243
     |in out err pid sema|
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
     in := 'out' asFilename readStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3246
     out := 'out2' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3247
     err := 'err' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3248
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3249
     sema := Semaphore new.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3250
     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
  3251
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3252
     The following will no longer work. monitorPid has disappeared 
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3253
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3254
     pid notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3255
	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3256
     ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3257
     in close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3258
     out close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3259
     err close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3260
     sema wait.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3261
     Transcript showCR:'finished'
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
    "Modified: / 21.3.1997 / 10:04:35 / dq"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3265
    "Modified: / 15.7.1997 / 16:03:51 / stefan"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3266
    "Modified: / 5.6.1998 / 19:03:51 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3267
    "Created: / 12.11.1998 / 14:39:20 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3268
! !
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3269
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3270
!UnixOperatingSystem class methodsFor:'executing OS commands-queries'!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3271
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3272
commandAndArgsForOSCommand:aCommandString
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3273
    "get a shell and shell arguments for command execution"
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
    |shell args|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3276
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3277
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3278
    "/ '/bin/sh -c <command>'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3279
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3280
    shell := '/bin/sh'.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3281
    args := Array with:'sh' with:'-c' with:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3282
    ^ Array with:shell with:args
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
    "Modified: / 20.1.1998 / 16:57:19 / md"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3285
    "Modified: / 5.6.1998 / 17:40:48 / cg"
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3288
getStatusOfProcess:aProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3289
    "wait for a process to terminate and fetch its exit status.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3290
     This is required to avoid zombie processes."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3291
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3292
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3293
    int status;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3294
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3295
    if (__isSmallInteger(aProcessId)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3296
	pid_t pid = (pid_t)(__intVal(aProcessId));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3297
	{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3298
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3299
# ifdef  NO_WAITPID
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3300
	    pid_t child;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3301
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3302
	    do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3303
		__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3304
		child = __wait (&status);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3305
		__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3306
		if (child < 0 && errno != EINTR) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3307
		    fprintf(stderr, "OS: child-wait errno=%d\n", errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3308
		    status = -1;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3309
		    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3310
		}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3311
	    } while (child != pid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3312
# else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3313
	    pid_t child;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3314
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3315
	    /* claus: the original did not care for EINTR here ... */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3316
	    do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3317
		__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3318
		child = __waitpid (pid, &status, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3319
		__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3320
	    } while ((child != pid) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3321
	    if (child != pid) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3322
		fprintf(stderr, "OS: child-waitpid errno=%d\n", errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3323
		status = -1;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3324
	    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3325
# endif /* NO_WAITPID */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3326
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3327
	RETURN ( __MKSMALLINT(status));
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3328
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3329
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3330
    self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3332
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3333
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3334
pathOfCommand:aCommand
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3335
    "find where aCommand's executable file is;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3336
     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
  3337
     return nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3338
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3339
    |path f fExt|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3340
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3341
    aCommand asFilename isAbsolute ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3342
	^ aCommand
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3343
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3344
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3345
    path := self getEnvironment:'PATH'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3346
    path notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3347
	(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3348
	    path isEmpty ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3349
		f := aCommand asFilename
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3350
	    ] ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3351
		f := path asFilename construct:aCommand.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3352
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3353
	    self executableFileExtensions do:[:ext |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3354
		ext notEmpty ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3355
		    fExt := (f pathName , ext) asFilename.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3356
		] ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3357
		    fExt := f.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3358
		].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3359
		fExt isExecutable ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3360
		    ^ fExt pathName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3361
		].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3362
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3363
	].
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
    ^ nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3366
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3367
    "unix:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3369
     OperatingSystem pathOfCommand:'fooBar'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3370
     OperatingSystem pathOfCommand:'ls'    
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3371
     OperatingSystem pathOfCommand:'cvs'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3372
     OperatingSystem pathOfCommand:'stx'   
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3373
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3374
    "windows:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3375
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3376
     OperatingSystem pathOfCommand:'windbg'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3377
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3378
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3379
    "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
  3380
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3381
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3382
!UnixOperatingSystem class methodsFor:'file access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3383
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3384
closeFd:anInteger
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3385
    "low level close of a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3386
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3387
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3388
     if (__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3389
	if (@global(ExternalStream:FileOpenTrace) == true) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3390
	    fprintf(stderr, "close [UnixOp] fd=%d\n", __intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3391
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3392
	close(__intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3393
	RETURN(self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3394
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3395
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3396
     ^ self primitiveFailed.
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3397
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3398
    "
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3399
     10 to:400 do:[:fd | OperatingSystem closeFd:fd]
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3400
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3401
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3402
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3403
createDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3404
    "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
  3405
     path, or relative to the current directory.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3406
     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
  3407
     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
  3408
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3409
    "/ if it already exists this is ok
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3410
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3411
    (self isDirectory:aPathName) ifTrue:[^ true].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3412
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3413
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3414
    if (__isString(aPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3415
	int ret;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3416
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3417
	ret = mkdir(__stringVal(aPathName), 0755);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3418
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3419
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3420
	    RETURN (false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3421
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3422
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3423
      }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3424
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3425
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3426
"/    self isUNIXlike ifTrue:[
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3427
"/      ^ self executeCommand:('mkdir 2>/dev/null ', newPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3428
"/    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3429
"/    ^ self executeCommand:('mkdir ', newPathName)
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
    self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3432
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3433
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3434
     OperatingSystem createDirectory:'foo'  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3435
    "
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
    "Modified: 20.12.1995 / 11:24:13 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3438
    "Modified: 29.6.1996 / 14:06:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3439
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3440
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3441
createFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3442
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3443
    ^ self open:pathName attributes:#(O_RDWR O_APPEND O_CREAT) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3444
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3445
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3446
createFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3447
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3448
    ^ 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
  3449
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3450
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3451
createHardLinkFrom:oldPath to:newPath
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3452
    "link the file 'oldPath' to 'newPath'. The link will be a hard link.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3453
     Return true if successful, false if not."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3454
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3455
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3456
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3457
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3458
    if (__isString(oldPath) && __isString(newPath)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3459
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3460
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3461
	    ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3462
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3463
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3464
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3465
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3466
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3467
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3468
	RETURN (true);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3469
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3470
%}.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3471
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3472
    "/ bad argument(s) given
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3473
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3474
    ^ self primitiveFailed 
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3475
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3476
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3477
     OperatingSystem linkFile:'foo' to:'bar'
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3478
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3479
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3480
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3481
createSymbolicLinkFrom:oldPath to:newPath
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3482
    "make a symbolic link for 'newPath' to the file 'oldPath'.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3483
     The link will be a soft (symbolic) link.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3484
     Return true if successful, false if not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3485
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3486
%{
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3487
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3488
    int ret;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3489
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3490
    if (__isString(oldPath) && __isString(newPath)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3491
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3492
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3493
	    ret = symlink((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3494
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3495
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3496
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3497
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3498
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3499
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3500
	RETURN (true);
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3501
    }
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3502
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3503
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3504
    (oldPath isString not or:[newPath isString not]) ifTrue:[
6992
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
	"/ bad argument(s) given
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3507
	"/
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3508
	^ self primitiveFailed 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3509
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3510
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3511
    "/
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3512
    "/ this Unix does not seem to support symbolic links
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3513
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3514
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3515
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3516
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3517
     OperatingSystem symbolicLinkFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3518
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3519
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3520
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3521
open:path attributes:attributes mode:modeInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3522
    "open a file, return an os specific fileHandle. 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3523
     openmode is a symbol defining the way to open
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3524
     valid modes are:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3525
	#O_RDONLY
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3526
	#O_RDWR
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3527
	#O_WRONLY
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3528
	#O_CREAT
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3529
	#O_APPEND
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3530
	#O_SYNC
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3531
	#O_LARGEFILE
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3532
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3533
     This is a private entry, but maybe useful to open/create a file in a special mode,
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3534
     which is proprietrary to the operatingSystem."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3535
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3536
    |error fileDescriptor|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3537
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3538
%{
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3539
    OBJ *ap;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3540
    int nAttributes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3541
    int fd;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3542
    int mode, openFlags = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3543
    int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3544
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3545
    if (!__isString(path)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3546
	error = @symbol(badArgument1);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3547
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3548
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3549
    if (!__isArray(attributes)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3550
	error = @symbol(badArgument2);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3551
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3552
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3553
    if (modeInteger == nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3554
	mode = 0644;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3555
    } else if (__isSmallInteger(modeInteger)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3556
	mode = __intVal(modeInteger);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3557
    } else {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3558
	error = @symbol(badArgument3);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3559
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3560
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3561
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3562
    nAttributes = __arraySize(attributes);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3563
    for (n = 0, ap = __arrayVal(attributes); n < nAttributes; n++) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3564
	OBJ attribute = ap[n];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3565
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3566
	if (attribute == @symbol(O_RDONLY)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3567
	    openFlags |= O_RDONLY;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3568
	} else if (attribute == @symbol(O_RDWR)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3569
	    openFlags |= O_RDWR;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3570
	} else if (attribute == @symbol(O_WRONLY)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3571
	    openFlags |= O_WRONLY;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3572
	} else if (attribute == @symbol(O_CREAT)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3573
	    openFlags |= O_CREAT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3574
	} else if (attribute == @symbol(O_APPEND)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3575
	    openFlags |= O_APPEND;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3576
	} else if (attribute == @symbol(O_EXCL)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3577
	    openFlags |= O_EXCL;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3578
	} else if (attribute == @symbol(O_TRUNC)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3579
	    openFlags |= O_TRUNC;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3580
	} else if (attribute == @symbol(O_LARGEFILE)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3581
#ifdef O_LARGEFILE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3582
	    openFlags |= O_LARGEFILE;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3583
#else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3584
	    error = @symbol(badArgument2);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3585
	    goto err;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3586
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3587
	} else if (attribute == @symbol(O_SYNC)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3588
#ifdef O_SYNC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3589
	    openFlags |= O_SYNC;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3590
#else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3591
	    error = @symbol(badArgument2);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3592
	    goto err;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3593
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3594
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3595
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3596
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3597
#if defined(O_NONBLOCK)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3598
    openFlags |= O_NONBLOCK;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3599
#else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3600
# if defined(O_NDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3601
    openFlags |= O_NDELAY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3602
# endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3603
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3604
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3605
again:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3606
    fd = open((char *) __stringVal(path), openFlags, mode);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3607
    if (fd < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3608
	if (errno == EINTR) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3609
	    __HANDLE_INTERRUPTS__;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3610
	    goto again;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3611
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3612
	    error = __mkSmallInteger(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3613
	    goto err;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3614
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3615
    }
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  3616
    fileDescriptor = __mkSmallInteger(fd);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3617
err:;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3618
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3619
    ^ fileDescriptor notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3620
	FileDescriptorHandle for:fileDescriptor.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3621
    ] ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3622
	(self errorHolderForNumber:error) reportError
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3623
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3624
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3625
    "
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3626
	self open:'/etc/hosts' attributes:#(O_RDONLY) mode:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3627
	self open:'/tmp/xxzz' attributes:#(O_RDWR O_CREAT) mode:8r611
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3628
	self open:'/etc/passwd' attributes:#(O_RDWR) mode:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3629
	self open:'/no one knows this file' attributes:#(O_RDONLY) mode:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3630
	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
  3631
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3632
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3633
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3634
openFileForAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3635
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3636
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3639
openFileForRead:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3640
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3641
    ^ self open:pathName attributes:#(O_RDONLY) mode:nil
6301
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3644
openFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3645
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3646
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3649
openFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3650
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3651
    ^ self open:pathName attributes:#(O_RDWR)  mode:nil
6301
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
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3654
openFileForWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3655
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3656
    ^ self open:pathName attributes:#(O_WRONLY)  mode:nil
6301
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3659
recursiveCopyDirectory:sourcePathName to:destination
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3660
    "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
  3661
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3662
7025
b172587b049b be careful with files with spaces in them (in recursiveRemove)
Claus Gittinger <cg@exept.de>
parents: 7003
diff changeset
  3663
    ^ 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
  3664
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3665
    "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
  3666
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3667
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3668
recursiveRemoveDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3669
    "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
  3670
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3671
7025
b172587b049b be careful with files with spaces in them (in recursiveRemove)
Claus Gittinger <cg@exept.de>
parents: 7003
diff changeset
  3672
    ^ self executeCommand:('rm -rf "' , fullPathName , '"')
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3673
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3674
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3675
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3676
     OperatingSystem recursiveRemoveDirectory:'foo'
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
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3679
    "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
  3680
!
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
removeDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3683
    "remove the directory named 'fullPathName'. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3684
     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
  3685
     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
  3686
     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
  3687
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3688
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3689
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3690
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3691
    if (__isString(fullPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3692
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3693
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3694
	    ret = rmdir((char *) __stringVal(fullPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3695
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3696
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3697
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3698
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3699
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3700
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3701
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3702
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3703
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3704
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3705
    "/ either not a string argument,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3706
    "/ or not supported by OS
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3709
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3710
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3711
     OperatingSystem createDirectory:'foo'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3712
     OperatingSystem removeDirectory:'foo'
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3715
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3716
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3717
removeFile:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3718
    "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
  3719
     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
  3720
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3721
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3722
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3723
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3724
    if (__isString(fullPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3725
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3726
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3727
	    ret = unlink((char *) __stringVal(fullPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3728
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3729
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3730
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3731
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3732
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3733
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3734
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3735
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3736
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3737
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3738
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3739
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3740
renameFile:oldPath to:newPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3741
    "rename the file 'oldPath' to 'newPath'. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3742
     Someone else has to care for the names to be correct and 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3743
     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
  3744
     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
  3745
     any invalid names.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3746
     Returns true if successful, false if not"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3747
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3748
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3749
    int ret, eno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3750
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3751
    if (__isString(oldPath) && __isString(newPath)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3752
#if defined(HAS_RENAME)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3753
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3754
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3755
	    ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3756
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3757
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3758
#else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3759
	ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3760
	if (ret >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3761
	    ret = unlink((char *) __stringVal(oldPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3762
	    if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3763
		eno = errno;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3764
		unlink((char *) __stringVal(newPath));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3765
		errno = eno;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3766
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3767
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3768
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3769
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3770
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3771
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3772
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3773
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3774
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3775
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3776
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3777
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3778
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3779
     OperatingSystem renameFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3780
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3781
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3782
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3783
truncateFile:aPathName to:newSize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3784
    "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
  3785
     This may not be supported on all architectures.
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
     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
  3788
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3789
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3790
#ifdef HAS_TRUNCATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3791
    int ret;
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
    if (__isString(aPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3794
     && __isSmallInteger(newSize)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3795
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3796
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3797
	    ret = truncate((char *) __stringVal(aPathName), __intVal(newSize));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3798
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3799
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3800
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3801
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3802
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3803
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3804
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3805
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3806
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3807
# ifdef HAS_FTRUNCATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3808
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3809
    int fd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3810
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3811
    if (__isString(aPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3812
     && __isSmallInteger(newSize)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3813
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3814
	    fd = open((char *) __stringVal(aPathName), 2);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3815
	} while (fd < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3816
	if (fd < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3817
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3818
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3819
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3820
        
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3821
	ret = ftruncate(fd, __intVal(newSize));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3822
	close(fd);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3823
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3824
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3825
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3826
	} 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3827
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3828
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3829
# endif /* using FTRUNCATE */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3830
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3831
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3832
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3833
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3834
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3835
!UnixOperatingSystem class methodsFor:'file access rights'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3836
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3837
accessMaskFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3838
    "return the access bits mask for numbers as returned by 
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3839
     OperatingSystem>>accessModeOf:
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3840
     and expected by OperatingSystem>>changeAccessModeOf:to:.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3841
     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
  3842
     (never hardcode 8rxxx into your code)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3843
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3844
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3845
#   ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3846
    /* posix systems should define these ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3847
#    define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3848
#    define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3849
#    define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3850
#    define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3851
#    define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3852
#    define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3853
#    define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3854
#    define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3855
#    define S_IXOTH 0001
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
#   endif
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
    if (aSymbol == @symbol(readUser)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3860
	RETURN ( __MKSMALLINT(S_IRUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3861
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3862
    if (aSymbol == @symbol(writeUser)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3863
	RETURN ( __MKSMALLINT(S_IWUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3864
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3865
    if (aSymbol == @symbol(executeUser)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3866
	RETURN ( __MKSMALLINT(S_IXUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3867
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3868
    if (aSymbol == @symbol(readGroup)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3869
	RETURN ( __MKSMALLINT(S_IRGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3870
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3871
    if (aSymbol == @symbol(writeGroup)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3872
	RETURN ( __MKSMALLINT(S_IWGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3873
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3874
    if (aSymbol == @symbol(executeGroup)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3875
	RETURN ( __MKSMALLINT(S_IXGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3876
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3877
    if (aSymbol == @symbol(readOthers)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3878
	RETURN ( __MKSMALLINT(S_IROTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3879
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3880
    if (aSymbol == @symbol(writeOthers)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3881
	RETURN ( __MKSMALLINT(S_IWOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3882
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3883
    if (aSymbol == @symbol(executeOthers)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3884
	RETURN ( __MKSMALLINT(S_IXOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3885
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3886
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3887
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3888
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3889
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3890
     OperatingSystem accessMaskFor:#readUser
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3891
    "
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3894
accessModeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3895
    "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
  3896
     group and others. Return nil if such a file does not exist.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3897
     Notice that the returned number is OS dependent - use the 
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3898
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3899
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3900
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3901
     this could have been implemented as:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3902
	(self infoOf:aPathName) at:#mode
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3903
     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
  3904
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3905
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3906
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3907
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3908
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3909
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3910
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3911
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3912
	printf("stat on '%s' for accessMode\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3913
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3914
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3915
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3916
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3917
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3918
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3919
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3920
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3921
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3922
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3923
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3924
	RETURN ( __MKSMALLINT(buf.st_mode & 0777) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3925
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3926
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3927
   ^ self primitiveFailed
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
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3930
    (OperatingSystem accessModeOf:'/') printStringRadix:8
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3931
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3932
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3933
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3934
changeAccessModeOf:aPathName to:modeBits
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3935
    "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
  3936
     You should construct this mask using accessMaskFor, to be OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3937
     independent. Return true if changed, 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3938
     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
  3939
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3940
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3941
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3942
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3943
    if (__isString(aPathName) && __isSmallInteger(modeBits)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3944
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3945
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3946
	    ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3947
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3948
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3949
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3950
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3951
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3952
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3953
	RETURN ( true );
3496
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3957
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3958
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3959
!UnixOperatingSystem class methodsFor:'file locking'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3960
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3961
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3962
   "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
  3963
    (such as returned by ExternalStream>>fileDescriptor).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3964
    On some systems, only advisory locks are available -
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3965
    these depends on other accessors to also perform the locking operation.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3966
    If they do not, they may still access the file 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3967
    (on some systems, locks are mandatory, on others, they are advisory). 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3968
    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
  3969
    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
  3970
    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
  3971
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3972
    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
  3973
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3974
    Notice, that not all OS's support these locks; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3975
    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
  3976
    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
  3977
    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
  3978
    argument."
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
    if (__isSmallInteger(aFileDescriptor)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3982
	int fd = __intVal(aFileDescriptor);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3983
	int lockArg;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3984
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3985
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3986
	 * claus: sigh - each one has a different interface ... 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3987
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3988
#if defined(F_SETLK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3989
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3990
	    /* 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3991
	     * new fcntl(SETLK) interface;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3992
	     * available on SYSV4 and Linux
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3993
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3994
	    struct flock flock;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3995
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3996
	    if (isSharedReadLock == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3997
		flock.l_type = F_RDLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3998
	    } else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3999
		flock.l_type = F_WRLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4000
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4001
	    flock.l_whence = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4002
	    flock.l_start = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4003
	    flock.l_len = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4004
	    lockArg = F_SETLK;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4005
# if defined(F_SETLKW)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4006
	    if (blockIfLocked == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4007
		lockArg = F_SETLKW;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4008
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4009
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4010
	    if (fcntl(fd, lockArg, &flock) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4011
		RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4012
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4013
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4014
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4015
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4016
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4017
# if defined(LOCK_EX) && defined(LOCK_UN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4018
	/* 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4019
	 * BSD 4.3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4020
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4021
	lockArg = LOCK_EX;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4022
#  if defined(LOCK_SH)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4023
	if (isSharedReadLock == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4024
	    lockArg = LOCK_SH
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4025
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4026
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4027
#  if defined(LOCK_NB)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4028
	if (blockIfLocked == false) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4029
	    lockArg |= LOCK_NB;
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 (flock(fd, lockArg) != -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
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4035
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4036
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4037
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4038
#  if defined(F_LOCK) && defined(F_UNLOCK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4039
	/* 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4040
	 * SYSV3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4041
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4042
	if (lockf(fd, F_LOCK, 0) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4043
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4044
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4045
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4046
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4047
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4048
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4049
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4050
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4051
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4052
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4053
supportsFileLinks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4054
    "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
  4055
     Typically, only unix returns true here."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4056
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4057
    ^ true
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4058
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4059
    "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
  4060
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4061
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4062
supportsFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4063
    "return true, if the OS supports file locking"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4064
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4065
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4066
#if defined(F_SETLK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4067
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4068
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4069
# if defined(LOCK_EX) && defined(LOCK_UN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4070
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4071
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4072
#  if defined(F_LOCK) && defined(F_UNLOCK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4073
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4074
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4075
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4076
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4077
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4078
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4079
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4080
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4081
     OperatingSystem supportsFileLocks
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4085
supportsNonBlockingFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4086
    "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
  4087
     (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
  4088
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4089
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4090
#if defined(F_SETLK) && defined(F_SETLKW)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4091
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4092
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4093
# 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
  4094
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4095
# endif
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4098
    ^ false
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4101
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4102
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4103
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4104
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4105
supportsSharedLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4106
    "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
  4107
     file locking."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4108
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4109
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4110
#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
  4111
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4112
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4113
# 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
  4114
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4115
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4116
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4117
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4118
    ^ false
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4121
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4122
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4123
!
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
unlockFD:aFileDescriptor
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4126
    "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
  4127
     which was previously aquired by #lockFD:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4128
     Return false, if the unlock failed 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4129
     (which may happens when a wrong fd is passed, 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4130
      no lock was set previously, or the systsem does not support locks).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4131
     Notice, that not all OS's support file locks; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4132
     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
  4133
     
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4134
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4135
    if (__isSmallInteger(aFileDescriptor)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4136
	int fd = __intVal(aFileDescriptor);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4137
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4138
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4139
	 * claus: sigh - each one has a different interface ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4140
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4141
#if defined(F_SETLK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4142
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4143
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4144
	     * new fcntl(SETLK) interface;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4145
	     * available on SYSV4 and Linux
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4146
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4147
	    struct flock flock;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4148
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4149
	    flock.l_type = F_UNLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4150
	    flock.l_whence = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4151
	    flock.l_start = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4152
	    flock.l_len = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4153
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4154
		RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4155
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4156
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4157
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4158
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4159
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4160
# if defined(LOCK_EX) && defined(LOCK_UN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4161
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4162
	 * BSD 4.3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4163
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4164
	if (flock(fd, LOCK_UN) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4165
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4166
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4167
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4168
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4169
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4170
#  if defined(F_LOCK) && defined(F_UNLOCK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4171
	/* 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4172
	 * SYSV3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4173
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4174
	if (lockf(fd, F_UNLOCK, 0) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4175
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4176
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4177
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4178
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4179
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4180
    }
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
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4183
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4184
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4185
!UnixOperatingSystem class methodsFor:'file queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4186
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4187
caseSensitiveFilenames
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4188
    "return true, if the OS has caseSensitive file naming.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4189
     On MSDOS, this will return false; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4190
     on a real OS, we return true."
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
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4193
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4194
    "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
  4195
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4196
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4197
compressPath:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4198
    "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
  4199
     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
  4200
     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
  4201
     if realPath and popen failed."
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
    |names n "{ Class: SmallInteger }" |
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4204
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4205
    names := pathName 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4206
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4207
    names := names asOrderedCollection.
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
     cut off initial double-slashes
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4210
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4211
    [names startsWith:#('' '')] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4212
	names removeFirst.
3496
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4215
     cut off double-slashes at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4216
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4217
    [names endsWith:#('')] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4218
	names removeLast.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4219
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4220
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4221
     cut off current-dir at beginning
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4222
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4223
    n := names size.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4224
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4225
	names removeFirst.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4226
	n := n - 1.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4227
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4228
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4229
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4230
     cut off parent-dirs at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4231
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4232
    [(n > 2) 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4233
     and:[(names endsWith:#('..'))
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4234
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4235
	names removeLast; removeLast.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4236
	n := n - 2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4237
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4238
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4239
    ^ names asStringWith:self fileSeparator 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4240
		    from:1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4241
		    to:n
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4242
		    compressTabs:false final:nil 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4243
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4244
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4245
     OperatingSystem compressPath:'./..'    
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4246
     OperatingSystem compressPath:'/foo/bar/baz/..'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4247
     OperatingSystem compressPath:'foo/bar/baz/..'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4248
     OperatingSystem compressPath:'foo/bar/baz/../'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4249
     OperatingSystem compressPath:'foo/bar/baz/..///' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4250
     OperatingSystem compressPath:'///foo/bar/baz/..///' 
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4253
    "Modified: 1.11.1996 / 20:13:48 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4254
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4255
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4256
fileSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4257
    "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
  4258
     This character differs for MSDOS and other systems,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4259
     (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
  4260
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4261
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4262
    ^ $/
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4263
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4264
    "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
  4265
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4266
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4267
getDiskInfoOf:aDirectoryPath
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4268
    "return some disk info. 
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4269
     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
  4270
     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
  4271
     On unix, the information returned is (at least):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4272
	freeBytes
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4273
	totalBytes
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4274
    "
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4275
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4276
    |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
  4277
     fileSystemIdx sizeIdx usedIdx availIdx capacityIdx mountIdx|
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4278
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4279
    p := PipeStream readingFrom:('df -k ' , aDirectoryPath).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4280
    p isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4281
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4282
    [
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4283
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4284
    ] ensure:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4285
	p close.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4286
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4287
"/ Transcript showCR:outputText asString.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4288
    outputText isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4289
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4290
    outputText := outputText asCollectionOfLines.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4291
    outputText size < 2 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4292
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4293
    keys := (outputText at:1) asLowercase asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4294
    values := (outputText at:2) asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4295
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4296
    "/ 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
  4297
    "/ on some rude Unix versions ...
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4298
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4299
    fileSystemIdx := 1.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4300
    sizeIdx := 2.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4301
    usedIdx := 3.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4302
    availIdx := 4.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4303
    capacityIdx := 5.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4304
    mountIdx := 6.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4305
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4306
    values size < 6 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4307
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4308
    info := IdentityDictionary new.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4309
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4310
    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
  4311
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4312
	info at:#percentUsed put:n
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4313
    ].
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
    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
  4316
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4317
	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
  4318
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4319
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4320
    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
  4321
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4322
	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
  4323
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4324
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4325
    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
  4326
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4327
	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
  4328
    ].
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 at:#mountPoint put:(values at:mountIdx).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4331
    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
  4332
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4333
    ^ info
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4334
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
     OperatingSystem getDiskInfoOf:'/'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4337
     OperatingSystem getDiskInfoOf:'.'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4338
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4339
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4340
    "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
  4341
!
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4342
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4343
getDriveList
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4344
    "return a list of volumes in the system. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4345
     On unix, no such thing like a volume exists 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4346
     - there, a syntetic list with root, home & current is returned. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4347
     On MSDOS, a list of drive letters is (eventually) returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4348
     On VMS, a list of volumes is (eventually) returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4349
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4350
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4351
    "/ default: retrurn array filled with
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4352
    "/ root, home and current directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4353
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4354
    ^ Array 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4355
	with:'/'
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4356
	with:(self getHomeDirectory)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4357
	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
  4358
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4359
    "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
  4360
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4361
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4362
getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4363
    "return info about mounted volumes. 
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4364
     The amount of information returned depends upon the OS, and is
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4365
     not guaranteed to be consistent across architectures.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4366
     On unix, the information returned is (at least):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4367
	mountPoint - mount point
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4368
	fileSystem - device or NFS-remotePath
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4369
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4370
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4371
    |p outputText keys values info infoEntry|
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4372
4933
bfa38904104e use df -k
Claus Gittinger <cg@exept.de>
parents: 4923
diff changeset
  4373
    p := PipeStream readingFrom:('df -k').
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4374
    p isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4375
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4376
    [
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4377
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4378
    ] ensure:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4379
	p close.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4380
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4381
"/ Transcript showCR:outputText asString.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4382
    outputText isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4383
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4384
    outputText := outputText asCollectionOfLines.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4385
    outputText size < 2 ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4386
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4387
    keys := (outputText at:1) asLowercase asCollectionOfWords.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4388
    "/ we may have to validate the following column indices
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4389
    "/ on some rude Unix versions ...
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4390
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4391
    info := OrderedCollection new.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4392
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4393
    outputText from:2 do:[:line |
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4394
	values := line asCollectionOfWords.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4395
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4396
	values size >= 2 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4397
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4398
	    infoEntry := IdentityDictionary new.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4399
	    infoEntry at:#mountPoint put:(values last).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4400
	    infoEntry at:#fileSystem put:(values first).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4401
	    info add:infoEntry.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4402
	]
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4403
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4404
    ^ info
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4405
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4406
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4407
     OperatingSystem getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4408
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4409
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4410
    "Modified: / 22.5.1999 / 00:32:13 / cg"
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4411
!
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4412
4201
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4413
getNullDevice
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4414
    "return the name of the OS's null device"
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4415
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4416
    ^ '/dev/null'
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4417
!
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4418
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4419
infoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4420
    "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
  4421
     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
  4422
     the returned object) is:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4423
	 type            - a symbol giving the files type
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4424
	 mode            - numeric access mode 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4425
	 uid             - owners user id
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4426
	 gid             - owners group id
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4427
	 size            - files size
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4428
	 id              - files number (i.e. inode number)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4429
	 accessed        - last access time (as Timestamp)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4430
	 modified        - last modification time (as Timestamp)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4431
	 statusChanged   - last status change time (as Timestamp)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4432
	 alternativeName     - (windows only:) the MSDOS name of the file
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4433
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4434
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4435
	 recordAttributes    - (VMS only:) recordAttributes
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4436
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4437
	 recordSize          - (VMS only:) record size.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4438
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4439
     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
  4440
     all of the information.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4441
     Return nil if such a file does not exist. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4442
     For symbolic links (if supported by the OS), 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4443
     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
  4444
     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
  4445
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4446
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
  4447
    |info type mode uid gid size id nLink
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4448
     atime mtime ctime 
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  4449
     aOStime mOStime cOStime|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4450
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4451
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4452
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4453
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4454
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4455
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4456
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4457
	printf("stat on '%s' for info\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4458
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4459
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4460
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4461
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4462
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4463
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4464
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4465
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4466
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4467
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4468
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4469
	switch (buf.st_mode & S_IFMT) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4470
	    case S_IFDIR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4471
		type = @symbol(directory);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4472
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4473
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4474
	    case S_IFREG:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4475
		type = @symbol(regular);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4476
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4477
# ifdef S_IFCHR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4478
	    case S_IFCHR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4479
		type = @symbol(characterSpecial);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4480
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4481
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4482
# ifdef S_IFBLK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4483
	    case S_IFBLK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4484
		type = @symbol(blockSpecial);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4485
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4486
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4487
# ifdef S_IFMPC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4488
	    case S_IFMPC:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4489
		type = @symbol(multiplexedCharacterSpecial);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4490
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4491
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4492
# ifdef S_IFMPB
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4493
	    case S_IFMPB:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4494
		type = @symbol(multiplexedBlockSpecial);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4495
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4496
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4497
# ifdef S_IFLNK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4498
	    case S_IFLNK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4499
		type = @symbol(symbolicLink);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4500
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4501
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4502
# ifdef S_IFSOCK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4503
	    case S_IFSOCK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4504
		type = @symbol(socket);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4505
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4506
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4507
# ifdef S_IFIFO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4508
	    case S_IFIFO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4509
		type = @symbol(fifo);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4510
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4511
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4512
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4513
		type = @symbol(unknown);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4514
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4515
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4516
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4517
	ino = buf.st_ino;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4518
	id = __MKUINT(ino);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4519
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4520
	mode = __MKSMALLINT(buf.st_mode & 0777);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4521
	uid = __MKSMALLINT(buf.st_uid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4522
	gid = __MKSMALLINT(buf.st_gid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4523
	nLink = __MKSMALLINT(buf.st_nlink);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4524
	size = __MKUINT(buf.st_size);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4525
	aOStime = __MKUINT(buf.st_atime);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4526
	mOStime = __MKUINT(buf.st_mtime);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4527
	cOStime = __MKUINT(buf.st_ctime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4528
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4529
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4530
    mode notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4531
	"/ now done lazy in FileStatusInfo
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4532
	"/ atime := AbsoluteTime fromOSTime:(aOStime * 1000).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4533
	"/ mtime := AbsoluteTime fromOSTime:(mOStime * 1000).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4534
	"/ ctime := AbsoluteTime fromOSTime:(cOStime * 1000).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4535
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4536
	info := FileStatusInfo
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4537
		    type:type 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4538
		    mode:mode 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4539
		    uid:uid 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4540
		    gid:gid 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4541
		    size:size 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4542
		    id:id 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4543
		    accessed:aOStime 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4544
		    modified:mOStime 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4545
		    statusChanged:cOStime
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4546
		    path:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4547
		    numLinks:nLink.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4548
	^ info
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4549
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4550
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4551
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4552
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4553
    OperatingSystem infoOf:'/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4554
    (OperatingSystem infoOf:'/') uid
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4555
    (OperatingSystem infoOf:'/') accessed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4556
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4557
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4558
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4559
isDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4560
    "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
  4561
     (i.e. exists and is a directory).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4562
     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
  4563
     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
  4564
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4565
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4566
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4567
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4568
    if (__isString(aPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4569
	struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4570
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4571
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4572
	printf("stat on '%s' for isDirectory\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4573
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4574
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4575
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4576
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4577
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4578
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4579
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4580
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4581
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4582
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4583
	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
  4584
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4585
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4586
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4587
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4588
    "an alternative implementation would be:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4589
	^ (self infoOf:aPathName) type == #directory
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
isExecutable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4594
    "return true, if the given file is executable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4595
     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
  4596
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4597
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4598
    int ret;
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
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4601
# ifdef TRACE_ACCESS_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4602
	printf("access on '%s' for executable\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4603
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4604
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4605
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4606
	    ret = access(__stringVal(aPathName), X_OK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4607
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4608
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4609
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4610
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4611
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4612
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4613
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4614
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4615
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4616
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4617
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4618
isReadable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4619
    "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
  4620
     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
  4621
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4622
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4623
    int ret;
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
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4626
# ifdef TRACE_ACCESS_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4627
	printf("access on '%s' for readable\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4628
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4629
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4630
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4631
	    ret = access(__stringVal(aPathName), R_OK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4632
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4633
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4634
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4635
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4636
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4637
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4638
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4639
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4640
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4641
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4642
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4643
isSymbolicLink:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4644
    "return true, if the given file is a symbolic link"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4645
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4646
    ^ (self linkInfoOf:aPathName) notNil
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4649
     OperatingSystem isSymbolicLink:'Make.proto'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4650
     OperatingSystem isSymbolicLink:'Makefile' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4651
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4652
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4653
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4654
isValidPath:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4655
    "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
  4656
     (i.e. the file or directory exists)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4657
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
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4660
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4661
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4662
    if (__isString(aPathName) || __isSymbol(aPathName) ) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4663
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4664
	printf("stat on '%s' for isValidPath\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4665
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4666
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4667
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4668
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4669
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4670
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4671
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4672
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4673
	    RETURN (false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4674
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4675
	RETURN ( ret ? false : true );
3496
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4678
    ^ self primitiveFailed
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4679
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4680
"/ alternative:
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4681
"/        ^ (self infoOf:aPathName) notNil
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4682
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4683
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4684
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4685
isWritable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4686
    "return true, if the given file is writable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4687
     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
  4688
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4689
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4690
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4691
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4692
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4693
# ifdef TRACE_ACCESS_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4694
	printf("access on '%s' for writable\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4695
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4696
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4697
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4698
	    ret = access(__stringVal(aPathName), W_OK);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4699
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4700
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4701
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4702
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4703
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4704
	RETURN ( ((ret == 0) ? true : false) );
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4708
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4709
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4710
linkInfoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4711
    "return a dictionary filled with info for the file 'aPathName',
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4712
     IFF aPathName is a symbolic link. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4713
     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
  4714
     (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
  4715
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4716
     The contents of the dictionary gives info about the link itself,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4717
     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
  4718
     in case of a symbolic link."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4719
     
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
  4720
    |info type mode uid gid size id nLink atime mtime ctime path|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4721
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4722
%{  /* STACK: 1200 */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  4723
#if defined(S_IFLNK)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4724
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4725
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4726
    char pathBuffer[1024];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4727
    unsigned INT ino;
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
    if (__isString(aPathName)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4730
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4731
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4732
	    ret = lstat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4733
	} while ((ret < 0) && (errno == EINTR));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4734
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4735
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4736
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4737
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4738
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4739
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4740
	switch (buf.st_mode & S_IFMT) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4741
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4742
		RETURN ( nil ); /* not a symbolic link */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4743
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4744
	    case S_IFLNK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4745
		type = @symbol(symbolicLink);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4746
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4747
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4748
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4749
	ino = buf.st_ino;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4750
	id = __MKUINT(ino);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4751
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4752
	mode = __MKSMALLINT(buf.st_mode & 0777);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4753
	nLink = __MKSMALLINT(buf.st_nlink);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4754
	uid = __MKSMALLINT(buf.st_uid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4755
	gid = __MKSMALLINT(buf.st_gid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4756
	size = __MKUINT(buf.st_size);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4757
	atime = __MKUINT(buf.st_atime);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4758
	mtime = __MKUINT(buf.st_mtime);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4759
	ctime = __MKUINT(buf.st_ctime);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4760
	if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4761
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4762
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4763
	} 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4764
	pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4765
	path = __MKSTRING(pathBuffer);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4766
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4767
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4768
    RETURN ( nil );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4769
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4770
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4771
    mode notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4772
	info := IdentityDictionary new.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4773
	^ FileStatusInfo
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4774
	    type:type 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4775
	    mode:mode 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4776
	    uid:uid 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4777
	    gid:gid 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4778
	    size:size 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4779
	    id:id 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4780
	    accessed:(AbsoluteTime fromOSTime:(atime * 1000)) 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4781
	    modified:(AbsoluteTime fromOSTime:(mtime * 1000)) 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4782
	    statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4783
	    path:path
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4784
	    numLinks:nLink.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4785
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4786
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4787
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4788
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4789
    OperatingSystem infoOf:'Make.proto'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4790
    OperatingSystem linkInfoOf:'Make.proto' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4791
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4792
    OperatingSystem infoOf:'resources/motif.style'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4793
    OperatingSystem linkInfoOf:'resources/motif.style' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4794
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4795
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4796
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4797
mountPoints
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4798
    "return a collection of mountPoints (aka. topDirectories of mounted file systems)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4799
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4800
    |procFS entries|
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4801
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4802
    procFS := '/proc/mounts' asFilename.
7640
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4803
    procFS exists ifFalse:[
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4804
        "/ TODO: add fallback code for other OS's
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4805
        ^ #() 
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4806
    ].
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4807
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4808
    entries := OrderedCollection new.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4809
    procFS readingLinesDo:[:eachLine |
7640
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4810
        |items mountInfo|
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4811
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4812
        items := eachLine asCollectionOfWords.
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4813
        mountInfo := (MountInfo new
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4814
            mountPointPath:(items at:2)        
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4815
            deviceOrRemotePath:(items at:1) 
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4816
            fsType:(items at:3) 
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4817
            attributeString:(items at:4)).
3a88d6dd9eba not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 7524
diff changeset
  4818
        entries add:mountInfo
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4819
    ].
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4820
    ^ entries
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4821
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4822
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4823
     OperatingSystem mountPoints
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4824
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4825
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4826
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4827
parentDirectoryName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4828
    "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
  4829
     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
  4830
     for other systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4831
     (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
  4832
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4833
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4834
    ^ '..'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4835
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4836
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4837
pathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4838
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4839
     - 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
  4840
     This method needs the path to be valid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4841
     (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
  4842
     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
  4843
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4844
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4845
    |p path command|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4846
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4847
    "some systems have a convenient function for this ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4848
    path := self primPathNameOf:pathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4849
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4850
    path isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4851
	(self isValidPath:pathName) ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4852
	    p := pathName.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4853
	    [(p size > 1)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4854
	     and:[p endsWith:(self fileSeparator)]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4855
	    ] whileTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4856
		p := p copyWithoutLast:1.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4857
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4858
	    ^ p
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4859
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4860
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4861
	(SlowFork==true or:[PipeFailed==true]) ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4862
	    PipeStream openErrorSignal handle:[:ex |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4863
		PipeFailed := true.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4864
		'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4865
		ex return.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4866
	    ] do:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4867
		"have to fall back ..."
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4868
		command := 'cd "' , pathName , '"; pwd'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4869
		p := PipeStream readingFrom:command.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4870
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4871
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4872
	    (p isNil or:[p atEnd]) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4873
		('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4874
	    ] ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4875
		path := p nextLine.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4876
		p close.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4877
	    ]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4878
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4879
	path isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4880
	    "/
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4881
	    "/ return the original - there is nothing else can we do
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4882
	    "/
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4883
	    path := pathName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4884
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4885
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4886
	    path := self compressPath:path
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4887
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4888
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4889
    ^ path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4890
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4891
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4892
     OperatingSystem pathNameOf:'.'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4893
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4894
     OperatingSystem pathNameOf:'../../..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4895
     OperatingSystem pathNameOf:'..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4896
     OperatingSystem pathNameOf:'/tmp////' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4897
     OperatingSystem pathNameOf:'/foo/bar' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4898
     OperatingSystem pathNameOf:'/foo/bar/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4899
     OperatingSystem pathNameOf:'/foo/bar//'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4900
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4901
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4902
    "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
  4903
    "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
  4904
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4905
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4906
primIdOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4907
    "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
  4908
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  4909
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4910
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4911
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4912
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4913
    OBJ retVal;
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
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4916
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4917
	printf("stat on '%s' for id\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4918
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4919
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4920
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4921
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4922
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4923
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4924
	if (ret >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4925
	    ino = buf.st_ino;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4926
	    retVal = __MKUINT(ino);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4927
	    RETURN (retVal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4928
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4929
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4930
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4931
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4932
    RETURN (nil);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4933
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4934
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4935
5492
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4936
primInfoOf:aPathName
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4937
   "for rel5 only"
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4938
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4939
   ^ self primitiveFailed
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4940
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4941
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4942
!
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4943
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4944
primPathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4945
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4946
     - thats the full pathname of the directory, starting at '/'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4947
     This method 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
  4948
     realPath library function.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4949
     Notice: if symbolic links are involved, the result may look different
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4950
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4951
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4952
    |path|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4953
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4954
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4955
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4956
    if (__isString(pathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4957
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4958
#ifdef HAS_GETCWD
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4959
	if (strcmp(__stringVal(pathName), ".") == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4960
	    char nameBuffer[MAXPATHLEN + 1];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4961
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4962
	    if (@global(CurrentDirectory) == nil) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4963
		if (getcwd(nameBuffer, MAXPATHLEN)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4964
		    OBJ d;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4965
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4966
		    @global(CurrentDirectory) = d = __MKSTRING(nameBuffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4967
		    __GSTORE(d);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4968
		}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4969
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4970
	    RETURN (@global(CurrentDirectory));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4971
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4972
#endif /* HAS_GETCWD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4973
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4974
#ifdef HAS_REALPATH
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4975
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4976
	    char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4977
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4978
	    if (realpath(__stringVal(pathName), nameBuffer)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4979
		RETURN ( __MKSTRING(nameBuffer) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4980
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4981
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4982
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4983
#endif /* ! HAS_REALPATH */
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
%}.
5451
2e21cd54b656 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5448
diff changeset
  4986
    ^ nil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4987
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4988
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4989
timeOfLastAccess:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4990
    "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
  4991
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4992
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4993
    "could be implemented as:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4994
	(self infoOf:aPathName) accessed 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4995
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4996
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4997
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4998
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4999
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5000
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5002
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5003
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5004
	printf("stat on '%s' for timeOfLastAccess\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5005
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5006
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5007
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5008
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5009
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5010
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5011
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5012
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5013
	    RETURN (nil);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5014
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5015
	osSeconds = __MKUINT(buf.st_atime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5016
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5017
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5018
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5019
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5020
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5021
    i notNil ifTrue:[^ i accessed].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5022
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5023
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5024
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5025
     OperatingSystem timeOfLastAccess:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5026
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5027
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5028
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5029
timeOfLastChange:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5030
    "return the time, when the file was last changed. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5031
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5032
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5033
    "could be implemented as:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5034
	(self infoOf:aPathName) modified
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5037
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5038
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5039
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5040
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5041
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5042
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5043
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5044
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5045
	printf("stat on '%s' for timeOfLastChange\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5046
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5047
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5048
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5049
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5050
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5051
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5052
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5053
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5054
	    RETURN ( nil );
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
	osSeconds = __MKUINT(buf.st_mtime);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5057
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5058
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5059
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5060
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5061
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5062
    i notNil ifTrue:[^ i modified].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5063
    ^ nil.
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5066
     OperatingSystem timeOfLastChange:'/'
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5070
typeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5071
    "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
  5072
     nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5073
     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
  5074
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5075
    |i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5076
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
     this could have been implemented as:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5079
	(self infoOf:aPathName) type 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5080
     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
  5081
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5082
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5083
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5084
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5085
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5086
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5087
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5088
# ifdef TRACE_STAT_CALLS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5089
	printf("stat on '%s' for type\n", __stringVal(aPathName));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5090
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5091
	__BEGIN_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5092
	do {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5093
	    ret = stat((char *) __stringVal(aPathName), &buf);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5094
	} while (ret < 0 && errno == EINTR);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5095
	__END_INTERRUPTABLE__
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5096
	if (ret < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5097
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5098
	    RETURN ( nil );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5099
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5100
	switch (buf.st_mode & S_IFMT) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5101
	    case S_IFDIR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5102
		RETURN ( @symbol(directory) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5103
	    case S_IFREG:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5104
		RETURN ( @symbol(regular) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5105
# ifdef S_IFCHR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5106
	    case S_IFCHR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5107
		RETURN ( @symbol(characterSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5108
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5109
# ifdef S_IFBLK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5110
	    case S_IFBLK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5111
		RETURN ( @symbol(blockSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5112
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5113
# ifdef S_IFLNK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5114
	    case S_IFLNK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5115
		RETURN ( @symbol(symbolicLink) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5116
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5117
# ifdef S_IFSOCK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5118
	    case S_IFSOCK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5119
		RETURN ( @symbol(socket) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5120
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5121
# ifdef S_IFIFO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5122
	    case S_IFIFO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5123
		RETURN ( @symbol(fifo) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5124
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5125
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5126
		RETURN ( @symbol(unknown) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5127
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5128
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5129
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5130
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5131
    i notNil ifTrue:[^ i type].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5132
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5133
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5134
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5135
     OperatingSystem typeOf:'/'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5136
     OperatingSystem typeOf:'.'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5137
     OperatingSystem typeOf:'Make.proto' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5138
     OperatingSystem typeOf:'resources/motif.style' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5139
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5140
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5141
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5142
volumeNameOf:aPathString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5143
    "return the volumeName of the argument, aPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5144
     - thats the name of the volume where aPath is.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5145
     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
  5146
     this always returns an empty string."
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
    ^ ''
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5149
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5150
    "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
  5151
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5152
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5153
!UnixOperatingSystem class methodsFor:'interrupts & signals'!
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
defaultSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5156
    "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
  5157
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5158
     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
  5159
     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
  5160
     default for SIGQUIT (^ \) is to dump core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5161
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5162
     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
  5163
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5165
%{  /* NOCONTEXT */
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 (__isSmallInteger(signalNumber)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5168
#ifdef SIG_DFL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5169
	signal(__intVal(signalNumber), SIG_DFL);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5170
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5171
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5172
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5173
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5174
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5175
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5176
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5177
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5179
    "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
  5180
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5181
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5182
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5183
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5184
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5185
     'normal ^C handling again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5186
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5187
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5188
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5189
disableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5190
    "turn off IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5191
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5192
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5193
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5194
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5195
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5196
#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
  5197
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5198
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5199
# if defined(SYSV4)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5200
	ret = ioctl(f, I_SETSIG, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5201
# else /*! SYSV4*/
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5202
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5203
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5204
	 * if already clear, there is no need for this syscall ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5205
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5206
	if (flags & FASYNC) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5207
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5208
	    if (ret >= 0) ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5209
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5210
	    ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5211
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5212
# endif /* !SYSV4 */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5213
	RETURN ( __MKSMALLINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5214
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5215
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5216
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5217
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5218
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5219
     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
  5220
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5221
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5222
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5223
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5224
disableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5225
    "disable (Unix-) signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5226
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5227
     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
  5228
     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
  5229
     handling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5230
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5231
     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
  5232
     a signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5233
     Use only for fully debugged stand alone applications."
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5236
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5237
    if (__isSmallInteger(signalNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5238
	int sigNo = __intVal(signalNumber);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5239
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5240
	if (sigNo == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5241
	    RETURN (self);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5242
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5243
#ifdef SIG_IGN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5244
	signal(sigNo, SIG_IGN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5245
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5246
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5247
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5248
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5249
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5250
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5251
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5252
    ^ self primitiveFailed
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
     'now, ^C is totally ignored ...' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5256
     OperatingSystem disableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5257
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5258
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5259
     '^C handled again.' printNewline
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5262
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5263
disableTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5264
    "disable timer interrupts.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5265
     WARNING: 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5266
	the system will not operate correctly with timer interrupts
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5267
	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
  5268
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5269
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5270
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5271
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5272
    struct itimerval dt;
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
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5275
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5276
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5277
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5278
    setitimer(ITIMER_REAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5279
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5280
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5281
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5282
# if defined(USE_SLOW_ALARM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5283
#  if defined(SIGALRM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5284
    alarm(0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5285
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5286
#  endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5287
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5288
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5289
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5290
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5291
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5292
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5293
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5294
enableChildSignalInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5295
    "enable childSignal interrupts 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5296
     (SIGCHLD, if the architecture supports it).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5297
     After enabling, these signals will send the message 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5298
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5299
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5300
    self enableSignal:(self sigCHLD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5301
!
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
enableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5304
    "turn on IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5305
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5306
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5308
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5309
#ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5310
    extern void __signalIoInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5311
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5312
    static int firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5314
#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
  5315
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5316
 * SIGIO/SIGPOLL - data available for I/O
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5317
 * (used to wake up waiting processes)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5318
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5319
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5320
# define THESIGNAL SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5321
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5322
# ifdef SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5323
#  define THESIGNAL SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5324
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5325
#  ifdef SIGURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5326
#   define THESIGNAL SIGURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5327
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5328
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5329
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5330
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5331
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5332
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5333
#ifdef HAS_SIGACTION
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5334
	    struct sigaction act = {0};
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5335
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5336
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5337
	     * Do not add SA_RESTART here. A signal can cause a
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5338
	     * thread switch, another thread can do a garbage collect
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5339
	     * and restarted system calls may write into old
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5340
	     * (collected) addresses.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5341
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5342
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5343
	    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
  5344
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5345
	    act.sa_handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5346
	    sigaction(THESIGNAL, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5347
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5348
# ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5349
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5350
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5351
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5352
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5353
	    vec.sv_handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5354
	    sigvec(THESIGNAL, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5355
# else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5356
	    signal(THESIGNAL, __signalIoInterrupt);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5357
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5358
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5359
	    firstCall = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5360
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5361
#undef THESIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5362
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5363
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5364
# if defined(SYSV4)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5365
	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
  5366
# else /*! SYSV4*/
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5367
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5368
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5369
	 * if already set, there is no need for this syscall ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5370
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5371
	if (flags & FASYNC) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5372
	    ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5373
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5374
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5375
	    if (ret >= 0) ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5376
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5377
# endif /*!SYSV4*/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5378
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5379
#if defined(F_SETOWN) || defined(FIOSETOWN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5380
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5381
	    int pid;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5382
	    int ok;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5383
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5384
	    pid = getpid();
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5386
# if defined(F_SETOWN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5387
	    ok = fcntl(f, F_SETOWN, pid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5388
	    /* printf("F_SETOWN returns %d (%d)\n", ret, errno); */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5389
# else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5390
	    ok = ioctl(f, FIOSETOWN, &pid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5391
	    /* printf("FIOSETOWN returns %d (%d)\n", ret, errno); */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5392
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5393
	    if (ok < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5394
		ret = ok;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5395
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5396
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5397
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5398
	RETURN ( __MKUINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5399
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5400
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5401
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5402
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5403
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5404
     or if the system does not support SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5405
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5406
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5407
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5408
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5409
enableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5410
    "enable (Unix-)signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5411
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5412
     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
  5413
     (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
  5414
     sends #signalInterrupt:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5415
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5416
     NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5417
     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
  5418
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5419
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5420
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5421
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5422
#ifdef NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5423
# define SIG_LIMIT NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5424
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5425
# ifdef SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5426
#  define SIG_LIMIT SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5427
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5428
#  ifdef SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5429
#   define SIG_LIMIT SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5430
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5431
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5432
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5433
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5434
#if defined(SIGPOLL) && !defined(SIGIO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5435
# define SIGIO SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5436
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5437
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5438
#ifdef SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5439
# define CHILD_SIGNAL   SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5440
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5441
# ifdef SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5442
#  define CHILD_SIGNAL  SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5443
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5444
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5445
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5446
    int sigNr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5447
#if defined(SIGINT) || defined(SIGQUIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5448
# ifndef __signalUserInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5449
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5450
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5451
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5452
#ifdef SIGFPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5453
# ifndef __signalFpExceptionInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5454
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5455
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5456
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5457
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5458
# ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5459
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5460
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5461
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5462
#ifdef CHILD_SIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5463
# ifndef __signalChildInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5464
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5465
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5466
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5467
#ifdef SIGPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5468
# ifndef __signalPIPEInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5469
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5470
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5471
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5472
#ifdef SIGBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5473
# ifndef __signalBUSInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5474
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5475
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5476
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5477
#ifdef SIGSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5478
# ifndef __signalSEGVInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5479
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5482
#if defined(SIGILL) || defined(SIGEMT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5483
# ifndef __signalTrapInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5484
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5485
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5486
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5487
#ifdef SIGALRM
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
  5488
# ifndef __signalTimerInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5489
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5490
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5491
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5492
#ifndef __signalInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5493
    extern void __signalInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5494
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5495
    void (*handler)(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5497
    if (__isSmallInteger(signalNumber)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5498
     && ((sigNr = __intVal(signalNumber)) >= 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5499
#ifdef SIG_LIMIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5500
     &&  (sigNr <= SIG_LIMIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5501
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5502
    ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5503
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5504
	 * standard signals are forced into standard handlers
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5505
	 * - all others go into general signalInterrupt
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5506
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5507
#if defined(SIGPOLL) && defined(SIGIO)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5508
	if (sigNr == SIGPOLL)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5509
	    sigNr = SIGIO;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5510
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5511
	switch (sigNr) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5512
	    case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5513
		/* enabling a non-supported signal */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5514
		RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5515
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5516
#ifdef SIGBREAK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5517
	    case SIGBREAK:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5518
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5519
#ifdef SIGINT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5520
	    case SIGINT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5521
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5522
#ifdef SIGQUIT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5523
	    case SIGQUIT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5524
#endif
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5525
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5526
		handler = __signalUserInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5527
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5528
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5529
#ifdef SIGFPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5530
	    case SIGFPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5531
		handler = __signalFpExceptionInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5532
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5533
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5534
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5535
#ifdef SIGPIPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5536
	    case SIGPIPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5537
		handler = __signalPIPEInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5538
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5539
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5540
#ifdef SIGBUS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5541
	    case SIGBUS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5542
		handler = __signalBUSInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5543
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5544
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5545
#ifdef SIGSEGV
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5546
	    case SIGSEGV:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5547
		handler = __signalSEGVInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5548
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5549
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5550
#ifdef SIGILL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5551
	    case SIGILL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5552
		handler = __signalTrapInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5553
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5554
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5555
#ifdef SIGEMT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5556
	    case SIGEMT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5557
		handler = __signalTrapInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5558
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5559
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5560
#ifdef SIGIO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5561
	    case SIGIO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5562
		handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5563
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5564
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5565
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5566
#ifdef CHILD_SIGNAL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5567
	    case CHILD_SIGNAL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5568
		handler = __signalChildInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5569
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5570
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5571
#ifdef SIGALRM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5572
	    case SIGALRM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5573
		handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5574
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5575
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5576
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5577
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5578
		handler = __signalInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5579
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5580
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5581
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5582
	{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5583
#ifdef HAS_SIGACTION
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5584
	    struct sigaction act = {0};
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5585
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5586
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5587
	     * Do not add SA_RESTART here. A signal can cause a
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5588
	     * thread switch, another thread can do a garbage collect
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5589
	     * and restarted system calls may write into old
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5590
	     * (collected) addresses.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5591
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5592
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5593
	    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
  5594
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5595
	    act.sa_handler = handler;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5596
	    sigaction(sigNr, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5597
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5598
# ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5599
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5600
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5601
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5602
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5603
	    vec.sv_handler = handler;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5604
	    sigvec(sigNr, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5605
# else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5606
	    (void) signal(sigNr, handler);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5607
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5608
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5609
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5610
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5611
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5612
	 * maybe, we should ret the old enable-status
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5613
	 * as boolean here ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5614
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5615
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5616
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5617
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5618
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5619
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5620
     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
  5621
     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
  5622
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5623
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5624
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5625
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5626
enableTimer:milliSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5627
    "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
  5628
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5629
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5630
    int millis;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5631
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5632
    millis = __intVal(milliSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5633
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5634
#ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5635
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5636
	static int firstCall = 1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5637
# ifndef __signalTimerInterrupt
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5638
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5639
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5640
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5641
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5642
# ifdef HAS_SIGACTION
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5643
	    struct sigaction act = {0};
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5644
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5645
	    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
  5646
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5647
	    act.sa_handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5648
	    sigaction(SIGALRM, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5649
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5650
#  ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5651
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5652
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5653
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5654
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5655
	    vec.sv_handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5656
	    sigvec(SIGALRM, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5657
#  else /* neither SIGACTION nor SIGVEC */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5658
	    signal(SIGALRM, __signalTimerInterrupt);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5659
#  endif /* stupid system  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5660
# endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5661
	    firstCall = 0;
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
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5664
#endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5665
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5666
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5667
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5668
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5669
	struct itimerval dt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5670
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5671
	dt.it_interval.tv_sec = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5672
	dt.it_interval.tv_usec = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5673
	dt.it_value.tv_sec = millis / 1000;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5674
	dt.it_value.tv_usec = (millis % 1000) * 1000;  
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5675
	setitimer(ITIMER_REAL, &dt, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5676
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5677
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5678
#else /* no ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5679
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5680
# ifdef USE_SLOW_ALARM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5681
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5682
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5683
	 * last fallback - use alarm (which only gives 1 second resolution).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5684
	 * 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
  5685
	 * with this. The consequence is that pressing CTRL-C processing and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5686
	 * thread switching will take place much delayed.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5687
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5688
	alarm(1);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5689
	RETURN(true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5690
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5691
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5692
#endif /* ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5693
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5694
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5695
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5696
6536
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5697
isFatalSignal:aNumber
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5698
   "return true if a signal with number aNumber is a fatal signal,
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5699
    i.e. some severe internal error occured"
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5700
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5701
   ^ (aNumber == self sigSEGV)
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5702
     or:[aNumber == self sigILL
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5703
     or:[aNumber == self sigBUS]]
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5704
!
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5705
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5706
killProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5707
    "kill a unix process.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5708
     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
  5709
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5710
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5711
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5712
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5713
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5714
    self sendSignal:(self sigKILL) to:processId.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5715
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5716
    "Modified: / 10.6.1998 / 11:59:12 / cg"
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5717
!
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5718
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5719
killProcessGroup:processGroupId
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5720
    "kill a unix process group.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5721
     The process has a no chance to do some cleanup.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5722
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5723
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5724
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5725
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5726
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5727
    self sendSignal:(self sigKILL) to:(processGroupId negated).
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5728
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5729
    "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
  5730
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5731
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5732
sendSignal:signalNumber to:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5733
    "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
  5734
     Returns false if any error occurred, true otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5735
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5736
     Do not confuse UNIX signals with Smalltalk-Signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5737
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5738
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5739
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5740
	      OperatingSystem>>getStatusOfProcess:aProcessId
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5741
	      if the signal terminates that process."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5742
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5743
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5744
    if (__bothSmallInteger(signalNumber, processId)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5745
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5746
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5747
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5748
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5749
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5750
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5751
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5752
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5753
    "/ either invalid argument (non-integers)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5754
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5755
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5756
    ^ self primitiveFailed
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5759
startSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5760
    "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
  5761
     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
  5762
     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
  5763
     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
  5764
     (which is of course less correct).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5765
     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
  5766
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5767
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5768
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5770
#ifndef __spyInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5771
    extern void __spyInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5772
#endif
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
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5775
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5776
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5777
# ifdef SIGVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5778
    signal(SIGVTALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5779
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5780
#  ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5781
    signal(SIGALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5782
#  else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5783
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5784
     * mhmh - system has neither SIGBTALRM nor SIGALRM ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5785
     * what should we do here ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5786
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5787
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5788
# endif
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
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5791
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5792
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5793
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5794
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5795
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5796
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5797
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5798
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5799
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5800
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5801
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5802
stopSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5803
    "stop spy timing - disable spy timer.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5804
     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
  5805
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5806
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5807
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5808
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5809
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5810
    struct itimerval dt;
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
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5813
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5814
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5815
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5816
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5817
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5818
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5819
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5820
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5821
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5822
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5823
terminateProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5824
    "terminate a unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5825
     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
  5826
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5827
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5828
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5829
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5830
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5831
    self sendSignal:(self sigTERM) to:processId.
3496
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
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5834
    "Modified: / 27.1.1998 / 20:05:47 / cg"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5837
terminateProcessGroup:processGroupId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5838
    "terminate a unix process group.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5839
     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
  5840
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5841
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5842
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5843
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5844
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5845
    self sendSignal:(self sigTERM) to:(processGroupId negated).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5846
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5847
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5848
    "Created: / 23.4.1996 / 16:40:34 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5849
    "Modified: / 27.1.1998 / 20:05:59 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5850
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5851
7292
db594b46a780 category changes
Claus Gittinger <cg@exept.de>
parents: 7289
diff changeset
  5852
!UnixOperatingSystem class methodsFor:'ipc support-UNIX'!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5853
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5854
makePTYPair
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5855
    "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
  5856
     nil on failure.
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5857
     This is a lowLevel entry, not for public use.
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5858
     See ExternalStream>>makePipe for a more user-friendly, public interface."
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5859
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5860
    |fdS fdM|    
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5861
                
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5862
%{       
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5863
    /*
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5864
     * Find a pseudo tty to use and open both sides.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5865
     *  _fdM receives the master file descriptor while _fdS
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5866
     *  receives the slave.  The master is opened with O_NDELAY as commonly
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5867
     *  needed in daemons such as rlogind and telnetd.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5868
     */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5869
3536
adad0d12c9a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3534
diff changeset
  5870
#ifdef IRIX5
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5871
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5872
    char *slaveName;
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5873
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5874
    slaveName = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5875
    if ((slaveName != 0) && (_fdM >= 0)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5876
	_fdS = open(slaveName, O_RDWR);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5877
	if (_fdS < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5878
	    (void)close(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5879
	    _fdS = _fdM = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5880
	}
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5881
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5882
	_fdM -1;
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5883
    }
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5884
    if ((_fdM >= 0) && (_fdS >= 0)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5885
	 fdM = __MKSMALLINT(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5886
	 fdS = __MKSMALLINT(_fdS);
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5887
    }
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5888
#   define NO_PTY_TEMPL
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5889
#endif /* IRIX5 */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5890
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5891
7003
3fee76c41c6a oops - SYSV4 is also defined for non UNIXWARE systems
Claus Gittinger <cg@exept.de>
parents: 7001
diff changeset
  5892
#ifdef UNIXWARE
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5893
    int _fdM, _fdS, ttygid;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5894
    char *slaveName;
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5895
#   include <grp.h>
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5896
    struct group *gr;
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5897
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5898
    if ((gr = getgrnam("tty")) != NULL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5899
	ttygid = gr->gr_gid;
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5900
    else
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5901
	ttygid = -1;
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5902
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5903
    _fdM = open("/dev/ptmx", O_RDWR /* |O_NDELAY */ );
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5904
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5905
    if (_fdM >= 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5906
	grantpt(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5907
	unlockpt(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5908
	slaveName = ptsname(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5909
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5910
	if (slaveName != NULL) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5911
	    /* printf("slave is: %s\n", slaveName); */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5912
	    _fdS = open(slaveName, O_RDWR);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5913
	    if (_fdS < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5914
		(void)close(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5915
		_fdS = _fdM = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5916
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5917
		ioctl(_fdS, I_PUSH, "ptem");          /* push ptem */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5918
		ioctl(_fdS, I_PUSH, "ldterm");        /* push ldterm */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5919
		/* (void) chown( slaveName, getuid(), ttygid );               */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5920
		/* (void) chmod( slaveName, S_IRUSR | S_IWUSR | S_IWGRP );    */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5921
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5922
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5923
	    (void)close(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5924
	    _fdS = _fdM = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5925
	}
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5926
    }
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5927
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5928
    if ((_fdM >= 0) && (_fdS >= 0)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5929
	 fdM = __MKSMALLINT(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  5930
	 fdS = __MKSMALLINT(_fdS);
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5931
    }
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5932
#   define NO_PTY_TEMPL
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5933
#endif /* SYSV4 */
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5934
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5935
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5936
#ifdef LINUX
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5937
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5938
#   define PT_INDEX      5
3550
6c3824d07eac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  5939
#   define PTY_1_CHARS  "pqrstuabcdevwxyz"
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5940
#   define PTY_2_CHARS  "0123456789abcdef"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5941
#endif /* LINUX */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5942
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5943
#ifdef solaris
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5944
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5945
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5946
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5947
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5948
#endif /* solaris */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5949
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5950
#ifdef aix
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5951
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5952
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5953
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5954
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5955
#endif /* aix */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5956
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5957
#ifdef next3
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5958
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5959
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5960
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5961
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5962
#endif /* next3 */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5963
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5964
#ifdef hpux
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5965
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5966
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5967
#   define PTY_1_CHARS  "pqrs"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5968
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5969
#endif /* hpux */
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5970
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5971
#if defined(__osf__)
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5972
#   define PTY_TEMPL    "/dev/ptyXX"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5973
#   define PT_INDEX      5
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5974
#   define PTY_1_CHARS  "pq"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5975
#   define PTY_2_CHARS  "0123456789abcdef"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5976
#endif /* osf1 */
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5977
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5978
#if defined(BSD) && !defined(PTY_TEMPL)
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5979
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5980
#   define PT_INDEX      5
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5981
#   define PTY_1_CHARS  "p"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5982
#   define PTY_2_CHARS  "0123456789abcdefghijklmnopqrstuv"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5983
#endif /* BSD */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5984
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5985
#ifdef NO_PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5986
# undef PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5987
#endif
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5988
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5989
#ifdef PTY_TEMPL
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5990
#   include <grp.h>
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5991
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5992
# ifdef OLD /* mhmh - suse linux6 places line into rodata ??? */
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5993
    static char line[] = PTY_TEMPL;
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5994
# else
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5995
    char line[128];
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5996
# endif
3575
39723f691a0e hp-cc does not recognize const keyword
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
  5997
    register CONST char *cp1, *cp2;
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5998
    int len, _fdM = -1, _fdS = -1, ttygid;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5999
    struct group *gr;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6000
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6001
# ifdef OLD
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6002
    len = sizeof(PTY_TEMPL) - 1;
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6003
# else
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6004
    strcpy(line, PTY_TEMPL);
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6005
    len = strlen(line);
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6006
# endif
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6007
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6008
    if ((gr = getgrnam("tty")) != NULL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6009
	ttygid = gr->gr_gid;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6010
    else
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6011
	ttygid = -1;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6012
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6013
    for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6014
	line[len-2] = * cp1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6015
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6016
	for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6017
	    line[PT_INDEX] = 'p';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6018
	    line[len-1] = *cp2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6019
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6020
	    if ((_fdM = open(line, O_RDWR, 0)) < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6021
		if (errno == ENOENT) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6022
		    _fdM = _fdS = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6023
		    goto getOutOfHere; /* out of ptys */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6024
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6025
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6026
		line[PT_INDEX] = 't';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6027
		(void) chown( line, getuid(), ttygid );
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6028
		(void) chmod( line, S_IRUSR | S_IWUSR | S_IWGRP );
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6029
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6030
		if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6031
		    goto getOutOfHere;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6032
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6033
		(void) close( _fdM );
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6034
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6035
	}
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6036
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6037
  getOutOfHere: ;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6038
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6039
    if ((_fdM >= 0) && (_fdS >= 0)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6040
	 fdM = __MKSMALLINT(_fdM);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6041
	 fdS = __MKSMALLINT(_fdS);
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6042
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6043
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6044
#endif /* PTY_TEMPL */
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6045
#undef NO_PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6046
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6047
%}.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6048
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6049
    fdM notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6050
	^ Array with:fdM with:fdS.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6051
    ].
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6052
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6053
    ^ nil
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6054
!
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6055
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6056
makePipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6057
    "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
  6058
     nil on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6059
     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
  6060
     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
  6061
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6062
    |fd1 fd2|    
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6063
                
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6064
%{       
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6065
     int fds[2];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6066
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6067
     if (pipe(fds) < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6068
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6069
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6070
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6071
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6072
     fd1 = __MKSMALLINT(fds[0]);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6073
     fd2 = __MKSMALLINT(fds[1]);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6074
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6075
    fd1 notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6076
	^ Array with:fd1 with:fd2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6077
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6078
    ^ nil
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6079
!
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6080
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6081
resetTerminalInputOutputModes:fd 
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6082
    "reset the terminal attributes"
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6083
%{
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6084
    struct termios switcher;
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6085
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6086
    printf("setMappingMaster fd:%d\n", __intVal(fd));
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6087
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6088
	if (tcgetattr( __intVal(fd), &switcher) < 0) RETURN (false); 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6089
	switcher.c_iflag = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6090
	switcher.c_oflag = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6091
	if (tcsetattr( __intVal(fd), TCSANOW, &switcher) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6092
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6093
	}
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6094
    }
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6095
%}.
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6096
    ^ false
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6097
!
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6098
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6099
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
  6100
    "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
  6101
%{
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6102
#ifdef TIOCSWINSZ
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6103
    struct winsize wsize;
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6104
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6105
    if (__isSmallInteger(fd)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6106
     && __isSmallInteger(w)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6107
     && __isSmallInteger(h)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6108
	wsize.ws_row = (unsigned short)__intVal(h);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6109
	wsize.ws_col = (unsigned short)__intVal(w);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6110
	if (ioctl(__intVal(fd), TIOCSWINSZ, (char *)&wsize) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6111
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6112
	}
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6113
    }
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6114
#endif
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6115
%}.
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6116
    ^ false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6117
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6118
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6119
!UnixOperatingSystem class methodsFor:'misc'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6120
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6121
closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6122
    "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
  6123
     getAddrInfo implementation:
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6124
	if it get interrupted (via a timer, for example), its domain-name
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6125
	socket remains open and is NEVER closed.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6126
	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
  6127
     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
  6128
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6129
    |p|
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6130
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6131
    p := PipeStream
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6132
	    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
  6133
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6134
    p linesDo:[:line |
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6135
	|words fd|
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6136
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6137
	words := line asCollectionOfWords.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6138
	"/ COMMAND PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6139
	words first = 'stx' ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6140
	    words second = (OperatingSystem getProcessId printString) ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6141
		(words fourth endsWith:'u') ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6142
		    (words fifth = 'IPv4') ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6143
			(words seventh = 'UDP') ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6144
			    (words last endsWith:'domain') ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6145
				fd := Number readFrom:(words fourth copyWithoutLast:1).
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6146
Transcript showCR:line.            
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6147
				OperatingSystem closeFd:fd.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6148
			    ]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6149
			]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6150
		    ]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6151
		]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6152
	    ]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  6153
	]
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6154
    ].
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6155
    p close.
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6156
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6157
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6158
     self closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6159
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6160
!
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6161
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6162
closePid:pid
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  6163
    "free pid resource.
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  6164
     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
  6165
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6166
    ^ true.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6167
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6168
    "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
  6169
    "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
  6170
    "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
  6171
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6172
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6173
slowFork:aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6174
    "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
  6175
     Only used internally on SYSV3 systems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6176
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6177
    SlowFork := aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6179
    "Modified: 22.4.1996 / 13:13:09 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6180
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6181
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6182
!UnixOperatingSystem class methodsFor:'os queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6183
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6184
executableFileExtensions
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6185
    "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
  6186
     Only req'd for msdos like systems ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6187
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6188
    ^ #('')
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6189
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6190
    "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
  6191
    "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
  6192
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6193
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6194
getDomainName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6195
    "return the domain this host is in.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6196
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6197
	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
  6198
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6199
    |name idx hostName|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6201
    DomainName notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6202
	^ DomainName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6203
    ].
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6204
    name := self primGetDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6205
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6206
	"/ fallBack
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6207
	name := self getEnvironment:'DOMAIN'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6208
	name isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6209
	    name := self getCommandOutputFrom:'domainname'
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6210
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6211
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6212
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6213
	"/ sometimes, we can extract the domainName from the hostName ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6214
	hostName := self primGetHostName.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6215
	hostName notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6216
	    (hostName occurrencesOf:$.) == 1 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6217
		idx := hostName indexOf:$..
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6218
		idx ~~ 0 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6219
		    name := hostName copyFrom:idx+1.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6220
		]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6221
	    ]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6222
	]. 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6223
	name isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6224
	    'UnixOperatingSystem [warning]: cannot find out domainname' errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6225
	    name := 'unknown'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6226
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6227
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6228
    DomainName := name.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6229
    ^ name
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6230
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6231
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6232
     OperatingSystem getDomainName
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6233
     OperatingSystem getHostName
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6234
     OperatingSystem primGetHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6235
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6236
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6237
    "Modified: 26.4.1996 / 10:04:54 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6238
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6240
getEnvironment:aStringOrSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6241
    "get an environment string"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6242
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6243
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6244
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6245
    char *env;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6246
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6247
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6248
    if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6249
	env =  getenv(__stringVal(aStringOrSymbol));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6250
	if (env) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6251
	    RETURN ( __MKSTRING(env) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6252
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6253
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6254
    }
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6255
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  6256
    ^ self primitiveFailed
3496
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6259
     OperatingSystem getEnvironment:'LANG'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6260
     OperatingSystem getEnvironment:'LOGIN'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6261
     OperatingSystem getEnvironment:'HOME'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6262
     OperatingSystem getEnvironment:'NNTPSERVER'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6263
     OperatingSystem getEnvironment:'MAIL'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6264
     OperatingSystem getEnvironment:'PATH'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6265
    "
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
getHostName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6269
    "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
  6270
     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
  6271
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6272
	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
  6273
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6274
    |name idx|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6275
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6276
    HostName notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6277
	^ HostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6278
    ].
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6279
    name := self primGetHostName.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6280
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6281
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6282
	"/ fallBack
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6283
	name := self getEnvironment:'HOST'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6284
	name isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6285
	    name := self getCommandOutputFrom:'hostname'
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6286
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6287
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6288
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6289
	'UnixOperatingSystem [warning]: cannot find out hostname' errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6290
	name := 'unknown'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6291
    ] ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6292
	"/ on some systems, the hostname already contains the domain.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6293
	"/ decompose it here.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6294
	(name occurrencesOf:$.) == 1 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6295
	    idx := name indexOf:$..
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6296
	    idx ~~ 0 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6297
		DomainName := name copyFrom:(idx+1).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6298
		name := name copyTo:(idx-1).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6299
	    ]
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
    HostName := 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 getHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6307
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6308
!
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
getLocaleInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6311
    "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
  6312
     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
  6313
     Possible fields are:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6314
	decimalPoint                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6315
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6316
	thousandsSep                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6317
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6318
	internationalCurrencySymbol     <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6319
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6320
	currencySymbol                  <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6321
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6322
	monetaryDecimalPoint            <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6323
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6324
	monetaryThousandsSeparator      <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6325
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6326
	positiveSign                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6327
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6328
	negativeSign                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6329
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6330
	internationalFractionalDigits   <Integer>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6331
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6332
	fractionalDigits                <Integer>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6333
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6334
	positiveSignPrecedesCurrencySymbol      <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6335
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6336
	negativeSignPrecedesCurrencySymbol      <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6337
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6338
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6339
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6340
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6341
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6342
	positiveSignPosition                            <Symbol>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6343
							one of: #parenthesesAround, 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6344
								#signPrecedes, 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6345
								#signSuceeds, 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6346
								#signPrecedesCurrencySymbol,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6347
								#signSuceedsCurrencySymbol
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6348
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6349
	negativeSignPosition                            <like above>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6350
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6351
     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
  6352
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6353
     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
  6354
     it should be used by applications as required.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6355
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6356
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6357
    |info val|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6358
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6359
    LocaleInfo notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6360
	"/ return the internal info; useful on systems which do not
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6361
	"/ support this.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6362
	^ LocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6363
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6364
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6365
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6366
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6367
    char *decimalPoint;         /* something like "." (US) or "," (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6368
    char *thousandsSep;         /* something like "," (US) or "." (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6369
    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
  6370
    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
  6371
    char *monDecimalPoint;      /* money: decimal point */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6372
    char *monThousandsSep;      /* money: thousands sep */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6373
    char *positiveSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6374
    char *negativeSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6375
    int   intFractDigits;       /* money: international digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6376
    int   fractDigits;          /* money: local digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6377
    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
  6378
    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
  6379
    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
  6380
    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
  6381
    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
  6382
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6383
				/*        2: sign succeeds the value & currency symbol */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6384
				/*        3: sign immediately precedes the currency symbol */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6385
				/*        4: sign immediately suceeds the currency symbol */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6386
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6387
#if defined(HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6388
    struct lconv *conf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6389
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6390
    conf = localeconv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6391
    if (conf) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6392
	decimalPoint = conf->decimal_point;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6393
	thousandsSep = conf->thousands_sep;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6394
	intCurrencySymbol = conf->int_curr_symbol;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6395
	currencySymbol = conf->currency_symbol;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6396
	monDecimalPoint = conf->mon_decimal_point;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6397
	monThousandsSep = conf->mon_thousands_sep;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6398
	positiveSign = conf->positive_sign;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6399
	negativeSign = conf->negative_sign;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6400
	intFractDigits = conf->int_frac_digits;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6401
	fractDigits = conf->frac_digits;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6402
	csPosPrecedes = conf->p_cs_precedes; 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6403
	csNegPrecedes = conf->n_cs_precedes; 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6404
	csPosSepBySpace = conf->p_sep_by_space; 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6405
	csNegSepBySpace = conf->n_sep_by_space; 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6406
	csPosSignPosition = conf->p_sign_posn;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6407
	csNegSignPosition = conf->n_sign_posn;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6408
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6409
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6410
    decimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6411
    thousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6412
    intCurrencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6413
    currencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6414
    monDecimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6415
    monThousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6416
    positiveSign =  (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6417
    negativeSign =(char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6418
    intFractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6419
    fractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6420
    csPosPrecedes = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6421
    csNegPrecedes = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6422
    csPosSepBySpace = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6423
    csNegSepBySpace = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6424
    csPosSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6425
    csNegSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6426
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6427
    if (decimalPoint) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6428
	val = __MKSTRING(decimalPoint);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6429
	__AT_PUT_(info, @symbol(decimalPoint), val);
3496
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
    if (thousandsSep) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6432
	val = __MKSTRING(thousandsSep);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6433
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6434
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6435
    if (intCurrencySymbol) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6436
	val = __MKSTRING(intCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6437
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
3496
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
    if (currencySymbol) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6440
	val = __MKSTRING(currencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6441
	__AT_PUT_(info, @symbol(currencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6442
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6443
    if (monDecimalPoint) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6444
	val = __MKSTRING(monDecimalPoint);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6445
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6446
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6447
    if (monThousandsSep) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6448
	val = __MKSTRING(monThousandsSep);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6449
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6450
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6451
    if (positiveSign) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6452
	val = __MKSTRING(positiveSign);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6453
	__AT_PUT_(info, @symbol(positiveSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6454
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6455
    if (negativeSign) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6456
	val = __MKSTRING(negativeSign);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6457
	__AT_PUT_(info, @symbol(negativeSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6458
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6459
    if (intFractDigits >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6460
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __MKSMALLINT(intFractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6461
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6462
    if (fractDigits >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6463
	__AT_PUT_(info, @symbol(fractionalDigits),  __MKSMALLINT(fractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6464
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6465
    if (csPosPrecedes >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6466
	if (csPosPrecedes == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6467
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6468
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6469
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6470
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6471
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6472
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6473
    if (csNegPrecedes >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6474
	if (csNegPrecedes == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6475
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6476
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6477
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6478
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6479
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6480
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6481
    if (csPosSepBySpace >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6482
	if (csPosSepBySpace == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6483
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6484
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6485
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6486
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6487
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6488
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6489
    if (csNegSepBySpace >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6490
	if (csNegSepBySpace == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6491
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6492
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6493
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6494
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6495
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6496
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6497
    switch (csPosSignPosition) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6498
	case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6499
	    val = @symbol(parenthesesAround);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6500
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6501
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6502
	case 1:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6503
	    val = @symbol(signPrecedes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6504
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6505
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6506
	case 2:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6507
	    val = @symbol(signSuceeds);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6508
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6509
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6510
	case 3:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6511
	    val = @symbol(signPrecedesCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6512
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6513
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6514
	case 4:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6515
	    val = @symbol(signSuceedsCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6516
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6517
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6518
	default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6519
	    val = nil;
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 (val != nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6522
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6523
    }
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
    switch (csNegSignPosition) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6526
	case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6527
	    val = @symbol(parenthesesAround);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6528
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6529
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6530
	case 1:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6531
	    val = @symbol(signPrecedes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6532
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6533
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6534
	case 2:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6535
	    val = @symbol(signSuceeds);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6536
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6537
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6538
	case 3:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6539
	    val = @symbol(signPrecedesCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6540
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6541
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6542
	case 4:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6543
	    val = @symbol(signSuceedsCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6544
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6545
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6546
	default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6547
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6548
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6549
    if (val != nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6550
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6551
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6552
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6553
    ^ info
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6556
     OperatingSystem getLocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6557
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6558
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6559
    "Created: 23.12.1995 / 14:19:20 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6560
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6561
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6562
getNetworkMACAddresses
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  6563
    "return a dictionary filled with 
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6564
        key -> name of interface 
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6565
        value -> the MAC adress (as ByteArray)
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6566
     for each interface"
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6567
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6568
    |addressArray nameArray noOfIf retDictionary error|
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6569
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6570
    noOfIf := 0.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6571
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6572
%{
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6573
#ifdef SIOCGIFHWADDR
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6574
    int             afinet_socket = -1;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6575
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6576
    struct ifconf   ifc;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6577
    struct ifreq    *ifr;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6578
    struct ifreq    ifreq;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6579
    unsigned char   buf[1024]; 
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6580
    int             n_ifs, i, countOfIf;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6581
    OBJ             t;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6582
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6583
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6584
    ** Open an INET socket
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6585
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6586
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6587
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6588
    if (afinet_socket < 0) {
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6589
        error = __MKSTRING("Cannot open socket");
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6590
        goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6591
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6592
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6593
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6594
    ** Get the list of network interfaces
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6595
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6596
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6597
    ifc.ifc_len = sizeof (buf);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6598
    ifc.ifc_buf = (caddr_t) buf;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6599
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6600
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {                                                 
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6601
        close(afinet_socket);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6602
        error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6603
        goto bad;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6604
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6605
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6606
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6607
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6608
    nameArray    = __MKARRAY(n_ifs);
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6609
    addressArray = __MKARRAY(n_ifs);
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6610
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6611
    if (nameArray == nil || addressArray == nil) {
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6612
        /* Creating a string wouldn/t work here */
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6613
        error = @symbol(allocationFailure);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6614
        goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6615
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6616
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6617
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6618
    ** Iterate of the list of the system's netif. Find all
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6619
    ** active interfaces and their ethernet addresses
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6620
    */
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6621
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6622
    countOfIf = 0;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6623
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6624
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6625
        /*
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6626
        ** Get Flags for this interface
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6627
        */
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6628
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6629
        memcpy(&ifreq, ifr, sizeof(ifreq)); 
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6630
        if (ioctl (afinet_socket, SIOCGIFFLAGS, &ifreq) < 0) {
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6631
            fprintf(stderr, "ioctl(SIOCGIFFLAGS) failed");
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6632
        } else {
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6633
            /*
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6634
            ** Get Hardware address for this interface
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6635
            */
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6636
            memcpy(&ifreq, ifr, sizeof(ifreq)); 
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6637
            if (ioctl (afinet_socket, SIOCGIFHWADDR, &ifreq) >= 0) {
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6638
                t = __MKBYTEARRAY(&ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6639
                __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6640
                t = __MKSTRING(&ifreq.ifr_ifrn.ifrn_name, IFNAMSIZ);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6641
                __arrayVal(nameArray)[countOfIf] = t; __STORE(addressArray, t);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6642
                countOfIf += 1;
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6643
            }
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6644
        }
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6645
    }
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6646
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6647
    noOfIf = __mkSmallInteger(countOfIf);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6648
bad: 
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6649
    if (afinet_socket >= 0)
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6650
        close(afinet_socket);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6651
#else
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6652
    error = @symbol(notSupported);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6653
#endif /* SIOCGIFHWADDR */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6654
%}.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6655
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6656
    retDictionary := Dictionary new:noOfIf.
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6657
    error notNil ifTrue:[
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6658
        self primitiveFailed:error.
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6659
        "return empty dictionary if proceed from error"
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6660
        ^  retDictionary.
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6661
    ].
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6662
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6663
    1 to:noOfIf do:[:cnt|
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6664
        retDictionary at:(nameArray at:cnt) put:(addressArray at:cnt).
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6665
    ].
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6666
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6667
    ^ retDictionary
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6668
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6669
    "
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6670
      OperatingSystem getNetworkMACAddresses
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  6671
    "
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  6672
!
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  6673
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6674
getProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6675
    "return the (unix-)processId"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6676
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6677
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6678
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6679
    int pid = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6680
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6681
    pid = getpid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6682
    RETURN ( __MKSMALLINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6683
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6684
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6685
     OperatingSystem getProcessId
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6686
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6687
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6688
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6689
getSystemID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6690
    "if supported by the OS, return the systemID;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6691
     a unique per machine identification.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6692
     WARNING:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6693
	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
  6694
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6695
%{  /* NO_CONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6696
#if defined(IRIX5) && !defined(HAS_GETHOSTID)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6697
    char idBuffer[MAXSYSIDSIZE];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6698
    int retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6699
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6701
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6702
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6703
	bcopy(idBuffer, __byteArrayVal(arr), MAXSYSIDSIZE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6704
	RETURN (arr);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6705
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6706
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6707
#if defined(HAS_GETHOSTID)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6708
    int runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6709
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6710
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6711
    runningId = gethostid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6712
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6713
    *(int *)(__byteArrayVal(arr)) = runningId;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6714
    RETURN (arr);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6715
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6716
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6717
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6718
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6719
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6720
	buffer[0] = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6721
	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6722
	    buffer[127] = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6723
	    if (strlen(buffer) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6724
		RETURN(__MKSTRING(buffer));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6725
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6726
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6727
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6728
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6729
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6730
    ^ 'unknown'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6731
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6732
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6733
     OperatingSystem getSystemID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6734
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6735
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6737
getSystemInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6738
    "return info on the system weare running on.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6739
     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
  6740
     otherwise, some simulated info is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6741
 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6742
     WARNING:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6743
       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
  6744
       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
  6745
       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
  6746
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6747
       This method is mainly provided to augment error reports with some system
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6748
       information. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6749
       (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
  6750
	may be based upon this info).
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6751
       Also, applications could enable/disable buffering or otherwise reduce
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6752
       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
  6753
       Your application may make use of available information for tuning,
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6754
       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
  6755
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6756
     The returned info may (or may not) contain:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6757
	#system -> some operating system identification (irix, Linux, nt, win32s ...) 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6758
	#version -> OS version (some os version identification)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6759
	#release -> OS release (3.5, 1.2.1 ...)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6760
	#node   -> some host identification (hostname)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6761
	#domain  -> domain name (hosts domain)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6762
	#machine -> type of CPU (i586, mips ...)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6763
     
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6764
     those are currently returned on some machines (no warranty)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6765
     linux:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6766
	#totalRam         -> total amount of memory available
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6767
	#sharedRam        -> amount of memory which is shared among processes
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6768
			     (i.e. shared code)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6769
	#bufferRam        -> amount used for buffers
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6770
	#swapSize         -> total size of swap space
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6771
	#freeSwap         -> free amount in swapSpace
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6772
	#extendedInstructions -> extended instruction set info
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6773
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6774
     osf:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6775
	#physicalRam      -> total amount of physical memory
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6776
	#cpuType          -> type of cpu (more detailed than machine)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6777
	#numberOfCPUs     -> number of cpus in box
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6778
        
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6779
     solaris:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6780
	#physicalRam      -> total amount of physical memory
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6781
	#availableRam     -> total available amount of physical memory (i.e. unused ram)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6782
	#freeRam          -> amount of free memory
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6783
	#numberOfCPUs     -> number of cpus in box (online CPUS)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6784
	[#dCacheSize]     -> bytes in data cache (only available on some solaris versions)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6785
	[#iCacheSize]     -> bytes in data cache (only available on some solaris versions)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6786
	[#instructionSets]-> instruction sets available (only available on some solaris versions)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6787
	[#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
  6788
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6789
     hpux:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6790
	#physicalRam      -> total amount of physical memory in box
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6791
	#activeRealMemory -> ? - read pstat documentation
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6792
	#activeVirtualRam -> ? - read pstat documentation
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6793
	#freeMemory       -> ? - read pstat documentation
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6794
	#realMemory       -> ? (amount of memory left to user programs)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6795
	#virtualRam       -> ? - read pstat documentation
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6796
    "
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6797
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6798
    |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
  6799
     physicalRam availableRam totalRam sharedRam bufferRam swapSize freeSwap
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6800
     numberOfCPUs pageSize physicalPages availablePages dCacheSize iCacheSize
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6801
     virtualRam activeVirtualRam realMemory activeRealMemory freeMemory
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6802
     instructionSets extendedInstructions platform|
3496
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
%{  /* STACK: 4096 */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6805
#ifdef LINUX
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  6806
# ifdef ELF /* old a.out unixes do not have this ... */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6807
    /* 
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6808
     * additional info available ...
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6809
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6810
    struct sysinfo infoBuffer;
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6811
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6812
    if (sysinfo(&infoBuffer) >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6813
	totalRam   = __MKUINT(infoBuffer.totalram);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6814
	sharedRam = __MKUINT(infoBuffer.sharedram);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6815
	bufferRam = __MKUINT(infoBuffer.bufferram);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6816
	swapSize  = __MKUINT(infoBuffer.totalswap);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6817
	freeSwap  = __MKUINT(infoBuffer.freeswap);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6818
    }
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  6819
# endif
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6820
#endif /* LINUX */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6821
4088
622551d3c0d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  6822
#if defined(hpux) && !defined(__GNUC__)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6823
# include <sys/pstat.h>
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6824
    struct pst_static stat_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6825
    struct pst_dynamic dynam_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6826
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6827
    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
  6828
    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
  6829
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6830
    physicalRam        = __MKUINT(stat_buf.physical_memory/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6831
    virtualRam         = __MKUINT(dynam_buf.psd_vm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6832
    activeVirtualRam   = __MKUINT(dynam_buf.psd_avm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6833
    realMemory         = __MKUINT(dynam_buf.psd_rm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6834
    activeRealMemory   = __MKUINT(dynam_buf.psd_arm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6835
    freeMemory         = __MKUINT(dynam_buf.psd_free/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6836
#endif
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6837
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6838
#if defined(HAS_UNAME)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6839
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6840
	struct utsname ubuff;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6841
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6842
	if (uname(&ubuff) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6843
	    sys  = __MKSTRING(ubuff.sysname);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6844
	    node = __MKSTRING(ubuff.nodename);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6845
	    rel  = __MKSTRING(ubuff.release);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6846
	    ver  = __MKSTRING(ubuff.version);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6847
	    mach = __MKSTRING(ubuff.machine);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6848
# ifdef HAS_UTS_DOMAINNAME
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6849
	    dom  = __MKSTRING(ubuff.domainname);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6850
# endif /* no HAS_UTS_DOMAINNAME */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6851
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6852
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6853
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6854
#else /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6855
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6856
    /*
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6857
     * use fallBack code below
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6858
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6859
#endif /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6860
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6861
#if defined(HAS_SYSINFO)
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6862
# if defined(SI_ARCHITECTURE)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6863
    if (arch == nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6864
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6865
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6866
	if (sysinfo(SI_ARCHITECTURE, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6867
	    arch = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6868
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6869
    }
4923
1cacdcfc82c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4922
diff changeset
  6870
# endif /* SI_ARCHITECTURE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6871
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6872
# if defined(SI_ISALIST)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6873
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6874
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6875
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6876
	if (sysinfo(SI_ISALIST, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6877
	    instructionSets = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6878
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6879
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6880
# endif /* SI_ISALIST */
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6881
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6882
# if defined(SI_PLATFORM)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6883
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6884
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6885
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6886
	if (sysinfo(SI_PLATFORM, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6887
	    platform = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6888
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6889
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6890
# endif /* SI_PLATFORM */
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6891
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6892
# if defined(SI_RELEASE)
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6893
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6894
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6895
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6896
	if (sysinfo(SI_RELEASE, buffer, sizeof(buffer))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6897
	    rel = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6898
	}
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6899
    }
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6900
# endif /* SI_RELEASE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6901
#endif /* HAS_SYSINFO */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6902
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6903
#if defined(HAS_GETDOMAINNAME)
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6904
    if (dom == nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6905
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6906
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6907
	if (getdomainname(buffer, sizeof(buffer)) == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6908
	    dom = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6909
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6910
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6911
#endif /* HAS_GETDOMAINNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6912
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6913
#if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6914
# ifdef _SC_NPROCESSORS_ONLN
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6915
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6916
	long val;
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6917
 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6918
	val = sysconf(_SC_NPROCESSORS_ONLN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6919
	if (val > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6920
	    numberOfCPUs = __MKINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6921
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6922
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6923
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6924
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6925
# if defined(_SC_PAGESIZE)
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6926
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6927
	long val;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6928
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6929
	val = sysconf(_SC_PAGESIZE);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6930
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6931
	    pageSize = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6932
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6933
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6934
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6935
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6936
# if defined(_SC_PHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6937
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6938
	long val;
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
	val = sysconf(_SC_PHYS_PAGES);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6941
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6942
	    physicalPages = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6943
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6944
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6945
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6946
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6947
# if defined(_SC_AVPHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6948
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6949
	long val;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6950
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6951
	val = sysconf(_SC_AVPHYS_PAGES);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6952
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6953
	    availablePages = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6954
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6955
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6956
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6957
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6958
# if defined(_SC_ICACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6959
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6960
	long val;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6961
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6962
	val = sysconf(_SC_ICACHE_SZ);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6963
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6964
	    iCacheSize = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6965
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6966
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6967
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6968
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6969
# if defined(_SC_DCACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6970
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6971
	long val;
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6972
 
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6973
	val = sysconf(_SC_DCACHE_SZ);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6974
	if (val != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6975
	    dCacheSize = __MKUINT(val);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6976
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6977
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6978
# endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6979
#endif /* HAS_SYSCONF */
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6980
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6981
#if defined(HAS_GETSYSINFO)
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6982
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6983
	INT index;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6984
	int retInt32 = 0;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6985
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6986
# if defined(GSI_CPU)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6987
	index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6988
	if (getsysinfo(GSI_CPU, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6989
	    switch (retInt32) {
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6990
#  ifdef VAX_780
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6991
		case VAX_780:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6992
		    cpuType = __MKSTRING("VAX_780");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6993
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6994
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6995
#  ifdef VAX_750
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6996
		case VAX_750:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6997
		    cpuType = __MKSTRING("VAX_750");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6998
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6999
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7000
#  ifdef VAX_730
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7001
		case VAX_730:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7002
		    cpuType = __MKSTRING("VAX_730");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7003
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7004
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7005
#  ifdef VAX_8600
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7006
		case VAX_8600:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7007
		    cpuType = __MKSTRING("VAX_8600");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7008
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7009
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7010
#  ifdef VAX_8200
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7011
		case VAX_8200:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7012
		    cpuType = __MKSTRING("VAX_8200");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7013
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7014
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7015
#  ifdef VAX_8800
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7016
		case VAX_8800:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7017
		    cpuType = __MKSTRING("VAX_8800");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7018
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7019
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7020
#  ifdef MVAX_I
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7021
		case MVAX_I:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7022
		    cpuType = __MKSTRING("MVAX_I");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7023
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7024
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7025
#  ifdef MVAX_II
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7026
		case MVAX_II:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7027
		    cpuType = __MKSTRING("MVAX_II");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7028
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7029
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7030
#  ifdef V_VAX
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7031
		case V_VAX:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7032
		    cpuType = __MKSTRING("V_VAX");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7033
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7034
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7035
#  ifdef VAX_3600
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7036
		case VAX_3600:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7037
		    cpuType = __MKSTRING("VAX_3600");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7038
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7039
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7040
#  ifdef VAX_6200
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7041
		case VAX_6200:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7042
		    cpuType = __MKSTRING("VAX_6200");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7043
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7044
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7045
#  ifdef VAX_3400
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7046
		case VAX_3400:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7047
		    cpuType = __MKSTRING("VAX_3400");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7048
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7049
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7050
#  ifdef C_VAXSTAR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7051
		case C_VAXSTAR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7052
		    cpuType = __MKSTRING("C_VAXSTAR");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7053
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7054
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7055
#  ifdef VAX_60
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7056
		case VAX_60:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7057
		    cpuType = __MKSTRING("VAX_60");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7058
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7059
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7060
#  ifdef VAX_3900
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7061
		case VAX_3900:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7062
		    cpuType = __MKSTRING("VAX_3900");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7063
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7064
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7065
#  ifdef DS_3100
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7066
		case DS_3100:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7067
		    cpuType = __MKSTRING("DS_3100");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7068
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7069
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7070
#  ifdef VAX_8820
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7071
		case VAX_8820:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7072
		    cpuType = __MKSTRING("VAX_8820");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7073
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7074
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7075
#  ifdef DS_5400
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7076
		case DS_5400:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7077
		    cpuType = __MKSTRING("DS_5400");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7078
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7079
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7080
#  ifdef DS_5800
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7081
		case DS_5800:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7082
		    cpuType = __MKSTRING("DS_5800");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7083
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7084
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7085
#  ifdef DS_5000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7086
		case DS_5000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7087
		    cpuType = __MKSTRING("DS_5000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7088
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7089
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7090
#  ifdef DS_CMAX
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7091
		case DS_CMAX:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7092
		    cpuType = __MKSTRING("DS_CMAX");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7093
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7094
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7095
#  ifdef VAX_6400
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7096
		case VAX_6400:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7097
		    cpuType = __MKSTRING("VAX_6400");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7098
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7099
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7100
#  ifdef VAXSTAR
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7101
		case VAXSTAR:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7102
		    cpuType = __MKSTRING("VAXSTAR");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7103
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7104
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7105
#  ifdef DS_5500
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7106
		case DS_5500:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7107
		    cpuType = __MKSTRING("DS_5500");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7108
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7109
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7110
#  ifdef DS_5100
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7111
		case DS_5100:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7112
		    cpuType = __MKSTRING("DS_5100");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7113
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7114
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7115
#  ifdef VAX_9000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7116
		case VAX_9000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7117
		    cpuType = __MKSTRING("VAX_9000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7118
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7119
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7120
#  ifdef DS_500_100
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7121
		case DS_500_100:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7122
		    cpuType = __MKSTRING("DS_500_100");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7123
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7124
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7125
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7126
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7127
#  ifdef ALPHA_ADU
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7128
		case ALPHA_ADU:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7129
		    cpuType = __MKSTRING("ALPHA_ADU");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7130
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7131
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7132
#  ifdef DEC_4000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7133
		case DEC_4000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7134
		    cpuType = __MKSTRING("DEC_4000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7135
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7136
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7137
#  ifdef DEC_3000_500
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7138
		case DEC_3000_500:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7139
		    cpuType = __MKSTRING("DEC_3000_500");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7140
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7141
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7142
#  ifdef DEC_7000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7143
		case DEC_7000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7144
		    cpuType = __MKSTRING("DEC_7000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7145
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7146
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7147
#  ifdef DS_5000_300
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7148
		case DS_5000_300:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7149
		    cpuType = __MKSTRING("DS_5000_300");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7150
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7151
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7152
#  ifdef DEC_3000_300
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7153
		case DEC_3000_300:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7154
		    cpuType = __MKSTRING("DEC_3000_300");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7155
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7156
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7157
#  ifdef DEC_2000_300
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7158
		case DEC_2000_300:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7159
		    cpuType = __MKSTRING("DEC_2000_300");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7160
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7161
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7162
#  ifdef DEC_2100_A500
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7163
		case DEC_2100_A500:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7164
		    cpuType = __MKSTRING("DEC_2100_A500");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7165
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7166
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7167
#  ifdef DEC_2100_A50
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7168
		case DEC_2100_A50:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7169
		    cpuType = __MKSTRING("DEC_2100_A50");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7170
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7171
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7172
#  ifdef ALPHA_KN20AA
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7173
		case ALPHA_KN20AA:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7174
		    cpuType = __MKSTRING("ALPHA_KN20AA");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7175
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7176
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7177
#  ifdef DEC_21000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7178
		case DEC_21000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7179
		    cpuType = __MKSTRING("DEC_21000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7180
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7181
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7182
#  ifdef DEC_AXPVME_64
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7183
		case DEC_AXPVME_64:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7184
		    cpuType = __MKSTRING("DEC_AXPVME_64");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7185
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7186
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7187
#  ifdef DEC_2100_C500
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7188
		case DEC_2100_C500:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7189
		    cpuType = __MKSTRING("DEC_2100_C500");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7190
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7191
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7192
#  ifdef DEC_AXPPCI_33
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7193
		case DEC_AXPPCI_33:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7194
		    cpuType = __MKSTRING("DEC_AXPPCI_33");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7195
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7196
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7197
#  ifdef DEC_1000
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7198
		case DEC_1000:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7199
		    cpuType = __MKSTRING("DEC_1000");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7200
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7201
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7202
#  ifdef EB64_PLUS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7203
		case EB64_PLUS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7204
		    cpuType = __MKSTRING("EB64_PLUS");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7205
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7206
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7207
#  ifdef LCA_EB66
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7208
		case LCA_EB66:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7209
		    cpuType = __MKSTRING("LCA_EB66");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7210
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7211
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7212
#  ifdef ALPHA_EB164
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7213
		case ALPHA_EB164:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7214
		    cpuType = __MKSTRING("ALPHA_EB164");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7215
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7216
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7217
#  ifdef DEC_EV45_PBP
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7218
		case DEC_EV45_PBP:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7219
		    cpuType = __MKSTRING("DEC_EV45_PBP");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7220
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7221
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7222
#  ifdef DEC_1000A
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7223
		case DEC_1000A:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7224
		    cpuType = __MKSTRING("DEC_1000A");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7225
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7226
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7227
#  ifdef DEC_4100
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7228
		case DEC_4100:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7229
		    cpuType = __MKSTRING("DEC_4100");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7230
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7231
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7232
#  ifdef DEC_ALPHAVME_224
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7233
		case DEC_ALPHAVME_224:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7234
		    cpuType = __MKSTRING("DEC_ALPHAVME_224");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7235
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7236
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7237
#  ifdef DEC_1000_5
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7238
		case DEC_1000_5:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7239
		    cpuType = __MKSTRING("DEC_1000_5");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7240
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7241
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7242
#  ifdef DEC_1000A_5
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7243
		case DEC_1000A_5:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7244
		    cpuType = __MKSTRING("DEC_1000A_5");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7245
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7246
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7247
#  ifdef DEC_EV56_PBP
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7248
		case DEC_EV56_PBP:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7249
		    cpuType = __MKSTRING("DEC_EV56_PBP");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7250
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7251
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7252
#  ifdef ALPHABOOK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7253
		case ALPHABOOK:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7254
		    cpuType = __MKSTRING("ALPHABOOK");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7255
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7256
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7257
#  ifdef DEC_ALPHAVME_320
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7258
		case DEC_ALPHAVME_320:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7259
		    cpuType = __MKSTRING("DEC_ALPHAVME_320");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7260
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7261
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7262
#  ifdef DEC_550
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7263
		case DEC_550:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7264
		    cpuType = __MKSTRING("DEC_550");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7265
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7266
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7267
#  ifdef DEC_6600
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7268
		case DEC_6600:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7269
		    cpuType = __MKSTRING("DEC_6600");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7270
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7271
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7272
#  ifdef UNKN_SYSTEM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7273
		case UNKN_SYSTEM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7274
		    cpuType = __MKSTRING("UNKN_SYSTEM");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7275
		    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7276
#  endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7277
		default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7278
		    cpuType = __MKSTRING("OTHER_DEC_SYSTEM");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7279
		    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7280
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7281
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7282
# endif /* GSI_CPU */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7283
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7284
# if defined(GSI_CPU_INFO)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7285
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7286
	 * 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
  7287
	 * 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
  7288
	 * V4.0 and higher ... (sigh)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7289
	 */
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7290
#  if defined GSI_PLATFORM_NAME
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7291
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7292
	    struct cpu_info cpuInfo;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7293
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7294
	    index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7295
	    if (getsysinfo(GSI_CPU_INFO, &cpuInfo, sizeof(cpuInfo), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7296
		cpuSpeed   = __MKUINT(cpuInfo.mhz);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7297
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7298
	}
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7299
#  endif
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7300
# endif /* GSI_CPU_INFO */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7301
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7302
# if defined(GSI_CPUS_IN_BOX)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7303
	index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7304
	if (getsysinfo(GSI_CPUS_IN_BOX, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7305
	    numberOfCPUs   = __MKUINT(retInt32);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7306
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7307
# endif /* GSI_CPUS_IN_BOX */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7308
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7309
# if defined(GSI_PHYSMEM)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7310
	index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7311
	if (getsysinfo(GSI_PHYSMEM, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7312
	    INT bytes = retInt32 * 1024;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7313
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7314
	    physicalRam   = __MKUINT(bytes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7315
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7316
# endif /* GSI_PHYSMEM */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7317
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7318
# if defined(GSI_PLATFORM_NAME) && (!defined(HAS_SYSINFO) || !defined(SI_PLATFORM))
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7319
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7320
	char buffer[128];
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7321
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7322
	index = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7323
	if (getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &index, NULL) > 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7324
	    platform = __MKSTRING(buffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7325
	}
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7326
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7327
# endif /* GSI_PLATFORM_NAME */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7328
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7329
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7330
#endif /* HAS_GETSYSINFO */
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7331
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7332
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7333
	extern OBJ __getInstructionSetInfo();
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7334
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7335
	extendedInstructions = __getInstructionSetInfo();
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7336
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7337
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7338
    sys isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7339
	sys := self getSystemType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7340
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7341
    node isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7342
	node := self getHostName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7343
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7344
    dom isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7345
	dom := self getDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7346
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7347
    mach isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7348
	mach := self getCPUType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7349
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7350
    arch isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7351
	arch := sys.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7352
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7353
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7354
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7355
    info at:#system put:sys.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7356
    info at:#node put:node.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7357
    rel notNil ifTrue:[info at:#release put:rel].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7358
    ver notNil ifTrue:[info at:#version put:ver].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7359
    mach notNil ifTrue:[info at:#machine put:mach].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7360
    arch notNil ifTrue:[info at:#architecture put:arch].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7361
    dom notNil ifTrue:[info at:#domain put:dom].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7362
    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7363
	physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7364
    ].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7365
    physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7366
    (pageSize notNil and:[availablePages notNil]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7367
	availableRam := pageSize * availablePages. "/ done here - could be largeInt.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7368
	availableRam notNil ifTrue:[info at:#availableRam put:availableRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7369
    ].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7370
    totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7371
    sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7372
    bufferRam notNil ifTrue:[info at:#bufferRam put:bufferRam].
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7373
    virtualRam notNil ifTrue:[info at:#virtualRam put:virtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7374
    activeVirtualRam notNil ifTrue:[info at:#activeVirtualRam put:activeVirtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7375
    realMemory notNil ifTrue:[info at:#realMemory put:realMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7376
    activeRealMemory notNil ifTrue:[info at:#activeRealMemory put:activeRealMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7377
    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
  7378
    swapSize notNil ifTrue:[info at:#swapSize put:swapSize].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7379
    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
  7380
    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
  7381
    cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7382
    cpuSpeed notNil ifTrue:[info at:#cpuSpeed put:cpuSpeed].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7383
    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7384
    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7385
    instructionSets notNil ifTrue:[info at:#instructionSets put:instructionSets].
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7386
    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
  7387
    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
  7388
    info at:#osType put:(self getOSType).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7389
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7390
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7391
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7392
     OperatingSystem getSystemInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7393
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7394
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7395
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7396
getSystemType
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7397
    "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
  7398
     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
  7399
     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
  7400
     Dont depend on this - use getOSType. I dont really see a point
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7401
     here ... 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7402
     (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
  7403
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7404
    |sys|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7405
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7406
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7407
#   ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7408
#    define SYS_STRING "next"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7409
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7410
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7411
#   ifdef IRIS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7412
#    define SYS_STRING "iris"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7413
#   endif
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
#   ifdef SYS_STRING
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7416
     sys = __MKSTRING(SYS_STRING);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7417
#    undef SYS_STRING
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7418
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7419
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
    sys isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7422
	^ self getOSType
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
    ^ sys
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7425
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7426
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7427
     OperatingSystem getSystemType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7428
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7429
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7430
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7431
isBSDlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7432
    "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
  7433
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7434
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7435
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7436
#if defined(BSD) || defined(MACH) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7437
    RETURN ( true );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7438
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7439
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7440
    ^ false
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7441
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7442
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7443
     OperatingSystem isBSDlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7444
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7445
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7446
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7447
isUNIXlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7448
    "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
  7449
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7450
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7451
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7452
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7453
     OperatingSystem isUNIXlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7454
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7455
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7456
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7457
maxFileNameLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7458
    "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
  7459
     CAVEAT:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7460
	 Actually, the following is somewhat wrong - some systems
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7461
	 support different sizes, depending on the volume.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7462
	 We return a somewhat conservative number here.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7463
	 Another entry, to query for volume specific max
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7464
	 will be added in the future."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7465
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7466
%{  /* NOCONTEXT */
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
    /*
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7469
     * 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
  7470
     */
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7471
#   if defined(MAXFILENAMELEN)
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7472
      RETURN ( __MKSMALLINT(MAXFILENAMELEN) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7473
#   else
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7474
#    if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7475
      RETURN ( __MKSMALLINT(255) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7476
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7477
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7478
#    ifdef realIX
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7479
       RETURN ( __MKSMALLINT(127) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7480
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7481
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7482
#    ifdef SYSV
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7483
       RETURN ( __MKSMALLINT(14) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7484
#    endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7485
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7486
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7487
    "unix default"
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
    ^ 14
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7490
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7491
    "
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7492
     OperatingSystem maxFileNameLength
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7493
    "
3496
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
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7496
maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7497
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7498
%{
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7499
     long l;
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7500
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7501
     l = sysconf(_SC_OPEN_MAX);
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7502
     if (l >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7503
	 RETURN(__mkSmallInteger(l));
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7504
     }
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7505
%}.
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7506
     self primitiveFailed
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7507
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7508
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7509
      self maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7510
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7511
!
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7512
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7513
maxPathLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7514
    "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
  7515
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7516
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7517
    RETURN ( __MKSMALLINT(MAXPATHLEN) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7518
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7519
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7520
     OperatingSystem maxPathLength   
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7521
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7522
!
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
pathSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7525
    "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
  7526
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7527
    ^ $:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7528
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7529
    "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
  7530
    "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
  7531
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7532
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7533
platformName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7534
    "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
  7535
     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
  7536
     #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
  7537
     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
  7538
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7539
    ^ #unix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7540
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7541
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7542
     OperatingSystem platformName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7543
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7544
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7545
    "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
  7546
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7547
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7548
primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7549
    "return the domain this host is in.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7550
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7551
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7552
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7553
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7554
#if defined(HAS_GETDOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7555
    char buffer[128];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7556
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7557
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7558
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7559
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7560
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7561
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7562
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7563
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7564
    if (uname(&ubuff) >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7565
	RETURN (__MKSTRING(ubuff.domainname));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7566
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7567
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7568
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7569
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7570
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7571
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7572
    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
  7573
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7574
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7575
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7576
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7577
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7578
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7579
    ^ nil
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7580
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7581
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7582
     OperatingSystem primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7583
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7584
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7585
    "Modified: 26.4.1996 / 10:04:54 / stefan"
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7586
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7587
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7588
primGetHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7589
    "return the hostname we are running on - if there is
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7590
     a HOST environment variable, we are much faster here ...
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7591
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7592
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7593
6960
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7594
%{  /* STACK: 100000 */
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7595
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7596
    /* sigh - with libc.so.6, gethostname needs huge amounts of stack
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7597
     * actually this is linux specific, but should not hurt others
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7598
     */
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7599
#if defined(HAS_GETHOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7600
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7601
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7602
    if (gethostname(buffer, sizeof(buffer)) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7603
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7604
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7605
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7606
# if defined(HAS_UNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7607
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7608
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7609
    if (uname(&ubuff) >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7610
	RETURN (__MKSTRING(ubuff.nodename));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7611
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7612
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7613
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7614
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7615
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7616
 
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7617
    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
  7618
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7619
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7620
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7621
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7622
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7623
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7624
    ^ nil 
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7625
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
     OperatingSystem getHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7628
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7629
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7630
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7631
setLocaleInfo:anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7632
    "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
  7633
     (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
  7634
     See description of fields in #getLocaleInfo.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7635
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7636
     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
  7637
     it should be used by applications as required."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7638
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7639
    LocaleInfo := anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7640
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7641
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7642
     |d|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7643
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7644
     d := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7645
     d at:#decimalPoint                 put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7646
     d at:#thousandsSeparator           put:','         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7647
     d at:#currencySymbol               put:'USD'       .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7648
     d at:#monetaryDecimalPoint         put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7649
     d at:#monetaryThousandsSeparator   put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7650
     d at:#fractionalDigits             put:2           .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7651
     d at:#positiveSign                 put:'+'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7652
     d at:#negativeSign                 put:'-'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7653
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7654
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7655
     OperatingSystem setLocaleInfo:d
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7656
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7657
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7658
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7659
supportsChildInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7660
    "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
  7661
     through interrupts (i.e. SIGCHILD)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7662
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7663
%{  /* NOCONTEXT */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  7664
#if defined(SIGCHLD) || defined(SIGCLD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7665
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7666
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7667
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7668
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7670
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7671
     OperatingSystem supportsChildInterrupts 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7672
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7673
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7674
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7675
supportsIOInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7676
    "return true, if the OS supports IO availability interrupts 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7677
     (i.e. SIGPOLL/SIGIO).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7678
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7679
     Currently, this mechanism does not work on all
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7680
     systems ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7681
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7682
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7683
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7684
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7685
  /* positive defines here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7686
   *  - irix5.2 does not work
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7687
   */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7688
#if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7689
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7690
# if defined(SIGIO) || defined(SIGPOLL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7691
#  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
  7692
#   if defined(F_SETOWN) || defined(FIOSETOWN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7693
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7694
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7695
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7696
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7697
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7698
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7699
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7700
#endif /* machines where it works */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7701
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7702
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7703
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7704
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7705
     OperatingSystem supportsIOInterrupts 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7706
    "
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7707
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7708
!
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
supportsNonBlockingIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7711
    "return true, if the OS supports nonblocking IO."
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7714
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7715
       RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7716
#endif
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
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7719
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7720
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7721
     OperatingSystem supportsNonBlockingIO  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7722
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7723
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7725
supportsSelect
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7726
    "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
  7727
     filedescriptors via select.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7728
     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
  7729
     intervals for I/O becoming ready."
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
%{  /* NOCONTEXT */
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
#if defined(sco)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7734
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7735
     * 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
  7736
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7737
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7738
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7739
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7740
    ^ true
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7743
     OperatingSystem supportsSelect 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7744
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7745
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7746
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7747
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7748
supportsSymbolicLinks
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7749
    "return true, if the OS supports symbolic (soft) links;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7750
     most UNIX'es do; many other OS's do not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7751
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7752
%{  /* NOCONTEXT */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7753
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7754
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7755
    /*
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7756
     * assume yes - if that is defined.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7757
     */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7758
    RETURN(true);
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7759
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7760
%}.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7761
    ^ false
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7762
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7763
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7764
     OperatingSystem supportsSymbolicLinks 
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7765
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7766
3496
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
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7769
!UnixOperatingSystem class methodsFor:'path queries'!
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7770
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7771
defaultSystemPath
5647
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7772
    "add additional directories to the systemPath 
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7773
     (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
  7774
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
  7775
    |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
  7776
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7777
    majorVersionNr := Smalltalk majorVersionNr.
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7778
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7779
    sysPath := super defaultSystemPath.
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7780
    #(
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7781
	'/usr/local/lib/stx'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7782
	'/usr/local/lib/smalltalk'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7783
	'/usr/lib/stx'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7784
	'/usr/lib/smalltalk'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7785
	'/lib/stx'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7786
	'/lib/smalltalk'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7787
	'/opt/stx'
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7788
	'/opt/smalltalk'
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7789
    ) do:[:d |
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7790
	(d asFilename isDirectory) ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7791
	    "/ try to guess a gnu-smalltalk; skip it
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7792
	    (d asFilename construct:'initialize.st') exists ifFalse:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7793
		releaseFile := d asFilename construct:'RELEASE'.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7794
		releaseFile exists ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7795
		    s := releaseFile readStreamOrNil.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7796
		    s notNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7797
			v := Integer readFrom:s onError:-1.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7798
			s close.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7799
			v == majorVersionNr ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7800
			    sysPath add:d
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7801
			] ifFalse:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7802
			    ('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE mismatch)') infoPrintCR.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7803
			]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7804
		    ] ifFalse:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7805
			('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE missing)') infoPrintCR.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7806
		    ]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7807
		]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7808
	    ]
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  7809
	]
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7810
    ].
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7811
    ^ sysPath
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7812
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7813
    "
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7814
     OperatingSystem defaultSystemPath
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7815
    "
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7816
! !
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7817
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7818
!UnixOperatingSystem class methodsFor:'private'!
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7819
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7820
osProcessStatusClass
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7821
    ^ OSProcessStatus
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7822
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7823
    "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
  7824
! !
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7825
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7826
!UnixOperatingSystem class methodsFor:'shared memory access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7827
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7828
shmAttach:id address:addr flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7829
    "low level entry to shmat()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7830
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7831
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7832
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7833
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7834
    void *address, *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7835
    int shmflg, shmid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7836
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7837
    if (__isSmallInteger(addr)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7838
     && __bothSmallInteger(flags, id)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7839
	shmaddr = (void *) __intVal(addr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7840
	shmflg = __intVal(flags);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7841
	shmid = __intVal(id);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7842
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7843
	address = shmat(shmid, shmaddr, shmflg);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7844
	if (address != (void *)-1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7845
	    RETURN (__MKEXTERNALBYTES(addr));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7846
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7847
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7848
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7849
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7850
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7851
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7852
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7853
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7854
    "Modified: 22.4.1996 / 13:15:12 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7855
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7856
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7857
shmDetach:addr
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7858
    "low level entry to shmdt()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7859
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7860
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7861
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7862
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7863
    void *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7864
    int rslt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7866
    if (__isSmallInteger(addr)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7867
	shmaddr = (void *) __intVal(addr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7868
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7869
	rslt = shmdt(shmaddr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7870
	if (rslt != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7871
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7872
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7873
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7874
	RETURN (false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7875
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7876
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7877
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7878
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7879
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7880
    "Modified: 22.4.1996 / 13:15:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7881
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7882
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7883
shmGet:key size:size flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7884
    "low level entry to shmget()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7885
     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
  7886
     - use the provided wrapper class SharedExternalBytes instead."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7887
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7888
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7889
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7890
    if (__bothSmallInteger(key, size)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7891
     && __isSmallInteger(flags)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7892
	int rslt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7893
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7894
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7895
	if (rslt != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7896
	    RETURN (__MKSMALLINT(rslt));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7897
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7898
	@global(LastErrorNumber) = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7899
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7900
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7901
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7902
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7903
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7904
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7905
    "Modified: 22.4.1996 / 13:14:46 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7906
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7907
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7908
!UnixOperatingSystem class methodsFor:'socket creation'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7909
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  7910
socketAccessor
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  7911
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  7912
    ^ SocketHandle
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  7913
!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  7914
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7915
socketWithDomain:domainArg type:typeArg protocol:protocolArg 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7916
    "set up socket with domain, type and protocol number.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7917
     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
  7918
     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
  7919
     #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7920
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7921
    ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7922
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  7923
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7924
!UnixOperatingSystem class methodsFor:'time and date'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7925
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7926
computeDatePartsOf:osTime for:aBlock
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7927
    "compute year, month and day from the OS time, osTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7928
     and evaluate the argument, a 3-arg block with these.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7929
     Conversion is to localtime including any daylight saving adjustments."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7930
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7931
    |year month day osSeconds i|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7932
7513
8a39ab36a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7511
diff changeset
  7933
    self obsoleteMethodWarning:'use #computeTimeAndDateFrom:osTime'.
8a39ab36a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7511
diff changeset
  7934
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7935
    osSeconds := osTime // 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7936
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7937
    struct tm* tmPtr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7938
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7939
    TIME_T tt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7940
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7941
    t = __longIntVal(osSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7942
    tt = (TIME_T)t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7943
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7944
    tmPtr = localtime(&tt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7945
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7946
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7947
    day = __MKSMALLINT(tmPtr->tm_mday);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7948
%}.
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7949
    year isNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  7950
	i := self computeTimeAndDateFrom:osTime.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  7951
	year := i year.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  7952
	month := i month.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  7953
	day := i day.
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7954
    ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7955
    aBlock value:year value:month value:day
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7958
     OperatingSystem computeDatePartsOf:0 for:[:y :m :d |
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  7959
	y printCR. m printCR. d printCR
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7960
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7961
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7962
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7963
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7964
computeOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7965
    "return the OS-dependent time for the given time and day. 
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7966
     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
  7967
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7968
    ^ self
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7969
	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
  7970
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7971
    "
5639
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  7972
     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
  7973
     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
  7974
     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
  7975
     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
  7976
    "
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7977
!
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7978
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7979
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7980
    "return the OS-dependent time for the given time and day. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7981
     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
  7982
     any daylight saving adjustings."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7983
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7984
    ^ self
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7985
	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
  7986
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7987
     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
  7988
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7989
!
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7990
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7991
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:utcBoolean
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7992
    "return the OS-dependent time for the given time and day. 
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7993
     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
  7994
     otherwise, in localtime including any daylight saving adjustings."
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  7995
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7996
    |osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7997
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7998
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7999
    struct tm tm;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8000
    TIME_T t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8002
    if (__bothSmallInteger(y, m) 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8003
     && __bothSmallInteger(d, h)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8004
     && __bothSmallInteger(min, s)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8005
	tm.tm_hour = __intVal(h);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8006
	tm.tm_min = __intVal(min);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8007
	tm.tm_sec = __intVal(s);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8008
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8009
	tm.tm_year = __intVal(y) - 1900;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8010
	tm.tm_mon = __intVal(m) - 1;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8011
	tm.tm_mday = __intVal(d);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8012
	tm.tm_isdst = -1;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8013
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8014
	t = mktime(&tm);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8015
	if (utcBoolean == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8016
	    t += TIMEZONE(&tm);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8017
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8018
	osSeconds = __MKUINT((INT)t);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8019
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8020
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8021
    osSeconds notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8022
	^ osSeconds * 1000 + millis
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8023
    ].    
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8024
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8025
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8026
    "
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8027
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 utc:true  
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8028
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 utc:false  
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8029
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8030
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8031
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8032
computeTimePartsOf:osTime for:aBlock
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8033
    "compute hours, minutes, seconds and milliseconds from the local osTime 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8034
     and evaluate the argument, a 4-arg block with these.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8035
     Conversion is to localtime including any daylight saving adjustments."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8036
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
  8037
    |hours minutes seconds millis i|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8038
7513
8a39ab36a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7511
diff changeset
  8039
    self obsoleteMethodWarning:'use #computeTimeAndDateFrom:osTime'.
8a39ab36a0f0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7511
diff changeset
  8040
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8041
    i := self computeTimeAndDateFrom:osTime.
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8042
    hours := i hours.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8043
    minutes := i minutes.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8044
    seconds := i seconds.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8045
    millis := i milliseconds.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8046
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8047
    aBlock value:hours value:minutes value:seconds value:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8048
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8049
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8050
     OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli |
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8051
	Transcript show:h; space; show:m; space; show:s; space; showCR:milli.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8052
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8053
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8054
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8055
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8056
computeUTCTimePartsOf:osTime for:aBlock
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8057
    "compute hours, minutes, seconds and milliseconds from the osTime 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8058
     and evaluate the argument, a 4-arg block with these.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8059
     Conversion is to UTC."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8060
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8061
    |hours minutes seconds millis 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
    osSeconds := osTime // 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8064
    millis := osTime \\ 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8065
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8066
    struct tm *tmPtr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8067
    long t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8068
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8069
    t = __longIntVal(osSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8070
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8071
    tmPtr = gmtime(&t);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8072
    hours = __MKSMALLINT(tmPtr->tm_hour);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8073
    minutes = __MKSMALLINT(tmPtr->tm_min);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8074
    seconds = __MKSMALLINT(tmPtr->tm_sec);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8075
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8076
    aBlock value:hours value:minutes value:seconds value:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8077
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8078
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8079
     OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli |
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8080
	h printCR. m printCR. s printCR. milli printCR
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8081
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8082
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8083
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8084
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8085
getMicrosecondTime
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8086
    "This returns the microsecond timers value - if available. 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8087
     On some machines, times with this precision may not be available,
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8088
     on those, the returned value may be rounded towards some internal
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8089
     clock resolution value."
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8090
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8091
    |seconds millis micros|
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8092
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8093
%{
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8094
    long __seconds = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8095
    long __millis = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8096
    long __micros = 0;
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8097
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8098
#if !defined(HAS_GETTIMEOFDAY)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8099
# if defined(HAS_FTIME)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8100
    struct timeb timebuffer;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8101
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8102
    ftime(&timebuffer);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8103
    __seconds = timebuffer.time;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8104
    __millis = timebuffer.millitm;
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8105
#   define HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8106
# endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8107
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8108
# ifndef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8109
#  if defined(SYSV) && defined(HZ)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8110
    /* 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8111
     * sys5 time - in ticks
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8112
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8113
    long ticks;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8114
    struct tms tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8115
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8116
    ticks = times(&tb);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8117
    __seconds = ticks / HZ;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8118
    ticks -= (__seconds * HZ);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8119
    __millis = ticks * 1000 / HZ;
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8120
#   define HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8121
#  endif /* old SYSV stuff */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8122
# endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8123
#endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8124
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8125
#ifndef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8126
    /* assume HAS_GETTIMEOFDAY 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8127
     * - will result in a linkage error
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8128
     * if not fixed.
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8129
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8130
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8131
    /*
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8132
     * bsd time
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8133
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8134
    struct timeval tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8135
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8136
    gettimeofday(&tb, NULL /* &tzb */);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8137
    __seconds = tb.tv_sec;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8138
    __micros = tb.tv_usec;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8139
    if (__micros >= (1000*1000)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8140
	printf("oops\n");
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8141
    }
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8142
#endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8143
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8144
#undef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8145
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8146
    seconds = __MKINT(__seconds);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8147
    millis = __MKINT(__millis);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8148
    micros = __MKINT(__micros);
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8149
%}.
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8150
    ^ (((seconds * 1000) + millis) * 1000) + micros
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
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8154
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8155
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8156
!
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8157
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8158
getMillisecondTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8159
    "This returns the millisecond timers value. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8160
     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
  8161
     LargeInteger arithmetic when doing timeouts and delays.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8162
     Since this value is wrapping around in regular intervals, this can only be used for 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8163
     short relative time deltas.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8164
     Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8165
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8166
     BAD DESIGN:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8167
	This should be changed to return some instance of RelativeTime,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8168
	and these computations moved there.
3496
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
     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
  8171
     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
  8172
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8173
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8174
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8175
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8176
    long t = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8177
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8178
#if !defined(HAS_GETTIMEOFDAY)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8179
# if defined(HAS_FTIME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8180
    struct timeb timebuffer;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8181
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8182
    ftime(&timebuffer);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8183
    t = (timebuffer.time * 1000) + timebuffer.millitm;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8184
#   define HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8185
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8186
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8187
# ifndef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8188
#  if defined(SYSV) && defined(HZ)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8189
    /* 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8190
     * sys5 time
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8191
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8192
    long ticks;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8193
    struct tms tb;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8194
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8195
    ticks = times(&tb);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8196
    t = (ticks * 1000) / HZ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8197
#   define HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8198
#  endif /* old SYSV stuff */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8199
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8200
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8201
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8202
#ifndef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8203
    /* assume HAS_GETTIMEOFDAY 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8204
     * - will result in a linkage error
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8205
     * if not fixed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8206
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8207
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8208
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8209
     * bsd time
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8210
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8211
    struct timeval tb;
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8212
    /* struct timezone tzb; */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8213
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8214
    gettimeofday(&tb, NULL /* &tzb */);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8215
    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
  8216
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8217
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8218
#undef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8219
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8220
    RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) );
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8221
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8222
    self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8223
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8224
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8225
getOSTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8226
    "This returns the OS time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8227
     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
  8228
     different OS's - some return the number of millis since jan, 1st 1970;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8229
     others since 1900. The Time classes are prepared for this, and 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8230
     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
  8231
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8232
     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
  8233
     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
  8234
     or use instances of Time, Date or AbsoluteTime to work with.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8235
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8236
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8237
    |time seconds millis|
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8238
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8239
    time := self primGetOSTime.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8240
    time isArray ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8241
	seconds := time at:1.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8242
	millis := time at:2.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8243
	time := (seconds * 1000) + millis
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8244
    ].
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8245
    ^ time
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8246
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8247
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8248
     OperatingSystem getOSTime printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8249
     Delay waitForSeconds:0.2.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8250
     OperatingSystem getOSTime printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8251
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8252
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8253
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8254
primGetOSTime
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8255
    "This returns the OS time.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8256
     The base of the returned value is not consistent across
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8257
     different OS's - some return the number of millis since jan, 1st 1970;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8258
     others since 1900. The Time classes are prepared for this, and 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8259
     converts as appropriate (by using my fromOSTime: conversion methods).
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8260
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8261
     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
  8262
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8263
     or use instances of Time, Date or AbsoluteTime to work with.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8264
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8265
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8266
    |seconds millis|
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8267
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8268
%{
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
    long t;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8271
    long _secs, _millis;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8272
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8273
#if !defined(HAS_GETTIMEOFDAY) 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8274
# if defined(HAS_FTIME)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8275
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8276
	struct timeb timebuffer;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8277
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8278
	ftime(&timebuffer);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8279
	_secs = timebuffer.time;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8280
	_millis = timebuffer.millitm;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8281
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8282
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8283
# endif /* HAS_FTIME */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8284
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8285
# ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8286
#  if defined(SYSV) && defined(HZ)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8287
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8288
	/* 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8289
	 * sys5 time; we have to fake the information
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8290
	 * the returned value is inexact.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8291
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8292
	long ticks;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8293
	struct tms tb;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8294
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8295
	_secs = time(0);   /* seconds since 1970 ... */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8296
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8297
	ticks = times(&tb);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8298
	t = (ticks * 1000) / HZ;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8299
	t = t % 1000;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8300
	_millis = __MKSMALLINT(t);
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8301
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8302
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8303
#  endif /* OLD SYSV stuff */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8304
# endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8305
#endif /* no HAS_GETTIMEOFDAY */
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
    /*
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8309
     * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8310
     * 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
  8311
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8312
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8313
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8314
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8315
	 * bsd time
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8316
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8317
	struct timeval tb;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8318
	/* struct timezone tzb; */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8319
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8320
	gettimeofday(&tb, NULL /* &tzb */);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8321
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8322
	_secs = tb.tv_sec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8323
	_millis = tb.tv_usec / 1000;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8324
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8325
#endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8326
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8327
    /* 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8328
     * mhmh long-long stuff seems not to work correctly 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8329
     * on all machines (sparc)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8330
     * being conservative here ...
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8331
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8332
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8333
#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(i386) && defined(LINUX)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8334
# define HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8335
#endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8336
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8337
#ifdef alpha64
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8338
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8339
	unsigned INT _lsecs, _lmillis, rslt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8340
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8341
	_lsecs = (INT)_secs;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8342
	_lmillis = (INT)_millis;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8343
	rslt = _lsecs * 1000 + _lmillis;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8344
	RETURN (__MKUINT(rslt));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8345
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8346
#else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8347
# ifdef HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8348
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8349
	unsigned long long _lsecs, _lmillis, rslt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8350
	unsigned low, hi;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8351
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8352
	_lsecs = (long long)_secs;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8353
	_lmillis = (long long)_millis;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8354
	rslt = _lsecs * 1000 + _lmillis;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8355
	low = rslt & 0xFFFFFFFF;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8356
	hi = rslt >> 32;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8357
	RETURN (__MKLARGEINT64(1, low, hi));
5488
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
# else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8360
    seconds = __MKUINT(_secs);
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8361
    millis = __MKUINT(_millis);
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8362
    RETURN (__ARRAY_WITH2(seconds, millis));
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8363
# endif /* long long */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8364
#endif /* alpha64 */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8365
%}.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8366
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
     OperatingSystem primGetOSTime printCR.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8369
     Delay waitForSeconds:0.2.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8370
     OperatingSystem primGetOSTime printCR.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8371
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8372
!
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8373
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8374
sleep:numberOfSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8375
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8376
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8377
    "cease ANY action for some time. This suspends the whole smalltalk
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8378
     (unix-) process for some time if running threadless;
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8379
     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
  8380
     only block until the next clock tick and return with the next
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8381
     timer interrupt.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8382
     Use either OperatingSystem>>millisecondDelay: (which makes all
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8383
     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
  8384
     only the calling thread sleep)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8386
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8387
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8388
    if (__isSmallInteger(numberOfSeconds)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8389
	sleep(__intVal(numberOfSeconds));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8390
	RETURN ( self );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8391
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8392
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8393
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8394
     argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8395
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8396
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8397
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8398
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8399
     OperatingSystem sleep:2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8400
    "
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8401
!
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8402
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8403
timeInfoFromSeconds:osSeconds localTime:isLocalTime
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8404
    "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
  8405
     OS-second value.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8406
     An internal helper"
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8407
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8408
    |year month day hours minutes seconds utcOffset 
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8409
     dst yDay wDay info|
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8410
7514
0335bec855aa *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7513
diff changeset
  8411
    info := self timeInfoClass new.
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8412
%{
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8413
    struct tm *tmPtr;
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8414
    INT t;
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8415
    TIME_T tt;
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8416
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8417
    t = __longIntVal(osSeconds);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8418
    tt = (TIME_T)t;
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8419
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8420
    if (isLocalTime == true) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8421
	tmPtr = localtime(&tt);
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8422
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8423
	tmPtr = gmtime(&tt);
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8424
    }
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8425
    hours = __MKSMALLINT(tmPtr->tm_hour);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8426
    minutes = __MKSMALLINT(tmPtr->tm_min);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8427
    seconds = __MKSMALLINT(tmPtr->tm_sec);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8428
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8429
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8430
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8431
    day = __MKSMALLINT(tmPtr->tm_mday);
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
    yDay = __MKSMALLINT(tmPtr->tm_yday+1);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8434
    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
  8435
    utcOffset = __MKSMALLINT(TIMEZONE(tmPtr));
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8436
    dst = (tmPtr->tm_isdst == 0 ? false : true);
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8437
%}.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8438
    info
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8439
	year:year
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8440
	month:month
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8441
	day:day
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8442
	hours:hours
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8443
	minutes:minutes
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8444
	seconds:seconds
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8445
	utcOffset:utcOffset
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8446
	dst:dst
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8447
	dayInYear:yDay
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8448
	dayInWeek:wDay.
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8449
    ^ info
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8450
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8451
    "
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8452
     OperatingSystem timeInfoFromSeconds:0 localTime:false
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8453
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8454
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8455
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8456
!UnixOperatingSystem class methodsFor:'users & groups'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8457
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8458
getEffectiveGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8459
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8460
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8461
    "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
  8462
     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
  8463
     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
  8464
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8465
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8466
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8467
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8468
    uid = getegid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8469
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8470
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8471
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8472
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8473
     OperatingSystem getEffectiveGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8474
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8475
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8476
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8477
getEffectiveUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8478
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8479
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8480
    "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
  8481
     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
  8482
     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
  8483
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8484
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8485
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8486
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8487
    uid = geteuid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8488
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8489
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8490
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8491
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8492
     OperatingSystem getEffectiveUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8493
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8494
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8495
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8496
getFullUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8497
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8498
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8499
    "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
  8500
     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
  8501
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8502
    |info gecos|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8503
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8504
    info := self userInfoOf:userID.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8505
    (info notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8506
    and:[info includesKey:#gecos]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8507
	gecos := info at:#gecos.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8508
	(gecos includes:$,) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8509
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8510
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8511
	^ gecos
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8512
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8513
    ^ self getUserNameFromID:userID
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8516
     OperatingSystem getFullUserNameFromID:0 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8517
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8518
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8519
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8520
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8521
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8522
    "Modified: 15.7.1996 / 12:44:21 / cg"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8525
getGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8526
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8527
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8528
    "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
  8529
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8530
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8531
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8532
    int uid;
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
    uid = getgid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8535
    RETURN ( __MKSMALLINT(uid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8536
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8537
    ^ 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
  8538
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8539
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8540
     OperatingSystem getGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8541
    "
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8544
getGroupNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8545
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8546
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8547
    "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
  8548
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8549
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8550
    struct group *g;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8551
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8552
    if (__isSmallInteger(aNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8553
	g = getgrgid(__intVal(aNumber));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8554
	if (g) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8555
	    RETURN ( __MKSTRING(g->gr_name) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8556
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8557
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8558
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8559
    ^ '???'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8560
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8561
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8562
     OperatingSystem getGroupNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8563
     OperatingSystem getGroupNameFromID:10
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8564
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8565
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8566
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8567
getHomeDirectory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8568
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8569
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8570
    "return the name of the users home directory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8571
     (i.e. yours)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8572
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8573
    ^ UnixOperatingSystem getEnvironment:'HOME'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8574
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8575
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8576
     OperatingSystem getHomeDirectory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8577
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8578
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8579
    "Modified: 24.1.1997 / 11:32:13 / cg"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8582
getLoginName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8583
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8584
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8585
    "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
  8586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8587
%{  /* NOCONTEXT */
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  8588
    static char cachedName[128];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8589
    static firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8590
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8591
    extern char *getlogin();
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
    char *name = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8594
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8595
    if (firstCall) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8596
	name = getlogin();
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8597
	if (! name || (name[0] == 0)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8598
	    name = getenv("LOGNAME");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8599
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8600
	if (name && (strlen(name) < sizeof(cachedName))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8601
	    strcpy(cachedName, name);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8602
	    firstCall = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8603
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8604
    } else {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8605
	name = cachedName;
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8606
    }
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8607
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8608
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8609
     * try a few common environment variables ...
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 (! name || (name[0] == 0) ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8612
	name = getenv("LOGIN");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8613
	if (! name || (name[0] == 0) ) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8614
	    name = getenv("LOGNAME");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8615
	    if (! name || (name[0] == 0) ) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8616
		name = getenv("USER");
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8617
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8618
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8619
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8620
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8621
     * nope - I really font know who you are.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8622
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8623
    if (! name || (name[0] == 0) ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8624
	name = "you";
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8627
    RETURN ( __MKSTRING(name) );
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8630
     OperatingSystem getLoginName
3496
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
!
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
getUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8635
    "{ Pragma: +optSpace }"
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
    "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
  8638
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8639
%{  /* NOCONTEXT */
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
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8642
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8643
    uid = getuid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8644
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8645
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8646
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8647
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8648
     OperatingSystem getUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8649
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8650
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8651
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8652
getUserNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8653
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8654
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8655
    "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
  8656
     This is the login name, not the fullName."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8657
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8658
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8659
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8660
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8661
    struct passwd *p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8662
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8663
    if (__isSmallInteger(aNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8664
	p = getpwuid(__intVal(aNumber));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8665
	if (p) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8666
	    RETURN ( __MKSTRING(p->pw_name) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8667
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8668
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8669
#endif /* unix-like */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8670
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8671
    aNumber == self getUserID ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8672
	^ self getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8673
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8674
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8675
    ^ '? (' , aNumber printString , ')'
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8678
     OperatingSystem getUserNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8679
     OperatingSystem getUserNameFromID:100
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8680
     OperatingSystem getUserNameFromID:9991 
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8684
userInfoOf:aNameOrID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8685
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8686
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8687
    "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
  8688
     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
  8689
     Notice, that not all systems provide (all of) this info;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8690
     DOS systems return nothing; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8691
     non-SYSV4 systems have no age/comment.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8692
     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
  8693
     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
  8694
     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
  8695
     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
  8696
     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
  8697
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8698
    |info name passw uid gid age comment
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8699
     gecos dir shell|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8701
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8702
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8703
    struct passwd *buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8704
    int ret;
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
    if (__isString(aNameOrID)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8707
	buf = getpwnam(__stringVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8708
    } else if (__isSmallInteger(aNameOrID)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8709
	buf = getpwuid(__intVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8710
    } else {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8711
	buf = (struct passwd *)0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8712
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8713
    if (buf) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8714
	name = __MKSTRING(buf->pw_name);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8715
#  ifndef NO_PWD_PASSWD
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8716
	passw = __MKSTRING(buf->pw_passwd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8717
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8718
#  ifdef SYSV4
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8719
	age = __MKSTRING(buf->pw_age);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8720
	comment = __MKSTRING(buf->pw_comment);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8721
#  endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8722
	dir = __MKSTRING(buf->pw_dir);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8723
#  ifndef NO_PWD_GECOS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8724
	gecos = __MKSTRING(buf->pw_gecos);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8725
#  endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8726
	shell = __MKSTRING(buf->pw_shell);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8727
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8728
	uid = __MKSMALLINT(buf->pw_uid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8729
	gid = __MKSMALLINT(buf->pw_gid);
3496
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
# endif /* has PWD */
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
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8734
    name isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8735
	aNameOrID == self getUserID ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8736
	    name := self getLoginName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8737
	].
3496
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
    name notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8740
	info at:#name put:name.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8741
    ] ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8742
	info at:#name put:'unknown'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8743
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8744
    passw notNil ifTrue:[info at:#passwd put:passw].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8745
    age notNil ifTrue:[info at:#age put:age].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8746
    comment notNil ifTrue:[info at:#comment put:comment].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8747
    gecos notNil ifTrue:[info at:#gecos put:gecos].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8748
    shell notNil ifTrue:[info at:#shell put:shell].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8749
    dir isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8750
	aNameOrID == self getUserID ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8751
	    dir := self getHomeDirectory
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8752
	]
3496
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
    dir notNil ifTrue:[info at:#dir put:dir].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8755
    uid notNil ifTrue:[info at:#uid put:uid].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8756
    gid  notNil ifTrue:[info at:#gid put:gid].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8757
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8758
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8759
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8760
     OperatingSystem userInfoOf:'root'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8761
     OperatingSystem userInfoOf:1
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8762
     OperatingSystem userInfoOf:'claus' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8763
     OperatingSystem userInfoOf:'fooBar' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8764
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8765
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8766
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8767
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8768
!UnixOperatingSystem class methodsFor:'waiting for events'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8770
blockingChildProcessWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8771
     "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
  8772
      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
  8773
      a subprocesses status (to avoid blocking)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8774
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8775
%{ /*NOCONTEXT*/
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  8776
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8777
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8778
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8779
    RETURN(true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8780
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8781
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8782
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8783
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8784
childProcessWait:blocking pid:pidToWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8785
    "{ Pragma: +optSpace }"
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
    "get status changes from child processes.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8788
     Return an OSProcessStatus or nil, if no process has terminated.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8789
     If blocking is true, we wait until a process changed state, 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8790
     otherwise we return immediately.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8791
     Note that win32 needs to know the HANDLE of the process on which 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8792
     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
  8793
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8794
    |pid status code core|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8795
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8796
    int p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8797
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8798
#if defined(HAS_WAITPID)
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
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8801
#   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
  8802
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8803
#else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8804
# if defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8805
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8806
    union wait s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8807
#   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
  8808
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8809
# 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
  8810
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8811
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8812
#   define __WAIT      wait(&s)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8813
#   define __BLOCKING_WAIT__ 1
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
    if (blocking != true) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8816
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8817
	 * We do not support nonBlocking waits, so signal an error
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8818
	 * Sorry about the goto, but with all these ifdefs ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8819
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8820
	goto done;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8821
    }
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8822
# endif /*!HAS_WAIT3*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8823
#endif  /*!HAS_WAITPID*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8824
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8825
#if !defined(WIFEXITED)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8826
# define WIFEXITED(stat)      (((int)((stat)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8827
# 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
  8828
# 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
  8829
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8830
# define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8831
# define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8832
# define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8833
#endif /*!WIFEXITED*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8834
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8835
#if !defined(WCOREDUMP)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8836
   /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8837
    * 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
  8838
    */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8839
# if defined(HAS_WAIT3)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8840
#  define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8841
# else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8842
#  define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8843
# endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8844
#endif /*!WCOREDUMP*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8845
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8846
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8847
    __BEGIN_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8848
#endif
3496
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
    do {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8851
	p = __WAIT;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8852
    } while (p == -1 && errno == EINTR);
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 __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8855
    __END_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8856
#  undef __BLOCKING_WAIT__
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8857
#endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8858
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8859
#undef __WAIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8860
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8861
    if (p == 0)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8862
	RETURN(nil)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8863
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8864
    if (p == -1) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8865
	if (errno == ECHILD)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8866
	    RETURN(nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8867
    } else {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8868
	pid = __MKSMALLINT(p);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8869
	if (WIFEXITED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8870
	    status = @symbol(exit);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8871
	    code = __MKSMALLINT(WEXITSTATUS(s));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8872
	    core = WCOREDUMP(s) ? true : false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8873
	} else if (WIFSIGNALED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8874
	    status = @symbol(signal);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8875
	    code = __MKSMALLINT(WTERMSIG(s));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8876
	} else if (WIFSTOPPED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8877
	    status = @symbol(stop);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8878
	    code = __MKSMALLINT(WSTOPSIG(s));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8879
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8880
#if defined(WIFCONTINUED)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8881
	else if (WIFCONTINUED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8882
	    status = @symbol(continue);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8883
	} 
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8884
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8885
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8886
done: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8887
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8888
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8889
    (status isNil or:[pid isNil]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8890
	^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8891
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8892
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8893
"/ 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
  8894
"/ show:' code: '; show:code; show:' core:'; showCR:core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8895
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8896
    ^ 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
  8897
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8898
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8899
     OperatingSystem childProcessWait:false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8900
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8901
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8902
    "Created: 5.1.1996 / 16:39:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8903
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8904
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8905
numAvailableForReadOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8906
    "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
  8907
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8908
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8909
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8910
     * 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
  8911
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  8912
# if 0 && defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8913
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8914
	int n;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8915
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8916
	if (__isSmallInteger(fd)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8917
	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8918
		RETURN (__MKINT(n));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8919
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8920
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8921
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8922
# endif /* FIONREAD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8923
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8924
    ^ (self readCheck:fd) ifTrue:[1] ifFalse:[0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8925
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8926
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8927
readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8928
    "return true, if data is available on a filedescriptor 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8929
     (i.e. read is possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8930
     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
  8931
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8932
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8933
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8934
     * 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
  8935
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  8936
#if 0 && defined(FIONREAD)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8937
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8938
	int result = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8939
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8940
	if (ioctl(__smallIntegerVal(fd), FIONREAD, &result) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8941
	    RETURN(result > 0 ? true : false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8942
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8943
    }
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  8944
#endif /* FIONREAD */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8945
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8946
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8947
    ^ super readCheck:fd
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
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8950
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8951
	readableInto:readableResultFdArray writableInto:writableResultFdArray 
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8952
	exceptionInto:exceptionResultFdArray
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8953
	withTimeOut:millis
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8954
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8955
    "wait for any fd in readFdArray (an Array of integers) to become ready for reading, 
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8956
     writeFdArray to become ready for writing, 
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8957
     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
  8958
     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
  8959
     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
  8960
     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
  8961
     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
  8962
     writableResultFdArray and exceptionResultFdArray respectively.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8963
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8964
     Return the (overall) number of selected filedescriptors.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8965
     readableResultFdArray, writableResultFdArray and exceptionResultFdArray will
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8966
     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
  8967
     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
  8968
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8969
%{
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8970
    fd_set rset, wset, eset;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8971
    struct timeval wt, et;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8972
    int maxF;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8973
    INT t;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8974
    int ret;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8975
    int cntR = 0, cntW = 0, cntE = 0;
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8976
    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
  8977
    int numFds = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8978
#ifndef __isArrayLike
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8979
# define __isArrayLike __isArray
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8980
#endif
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8981
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8982
    if (!__isSmallInteger(millis)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8983
	goto fail;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  8984
    }
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8985
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8986
    if (readableResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8987
	if (! __isArrayLike(readableResultFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8988
	    goto fail;    
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8989
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8990
	resultSizeReadable = __arraySize(readableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8991
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8992
    if (writableResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8993
	if (! __isArrayLike(writableResultFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8994
	    goto fail;    
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8995
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8996
	resultSizeWritable = __arraySize(writableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8997
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  8998
    if (exceptionResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  8999
	if (! __isArrayLike(exceptionResultFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9000
	    goto fail;    
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9001
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9002
	resultSizeException = __arraySize(exceptionResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9003
    }
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9004
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9005
    FD_ZERO(&rset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9006
    FD_ZERO(&wset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9007
    FD_ZERO(&eset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9008
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9009
    maxF = -1;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9010
    if (__isNonNilObject(readFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9011
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9012
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9013
	if (! __isArrayLike(readFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9014
	    goto fail;    
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9015
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9016
	count = __arraySize(readFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9017
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9018
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9019
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9020
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9021
	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9022
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9023
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9024
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9025
			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
  9026
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9027
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9028
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9029
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9030
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9031
		    if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9032
			FD_SET(f, &rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9033
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9034
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9035
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9036
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9037
			    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
  9038
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9039
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9040
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9041
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9042
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9043
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9044
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9045
    if (__isNonNilObject(writeFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9046
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9047
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9048
	if (! __isArrayLike(writeFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9049
	    goto fail;    
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9050
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9051
	count = __arraySize(writeFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9052
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9053
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9054
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9055
	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9056
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9057
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9058
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9059
			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
  9060
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9061
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9062
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9063
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9064
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9065
		    if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9066
			FD_SET(f, &wset);       
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9067
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9068
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9069
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9070
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9071
			    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
  9072
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9073
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9074
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9075
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9076
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9077
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9078
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9079
    if (__isNonNilObject(exceptFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9080
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9081
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9082
	if (! __isArrayLike(exceptFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9083
	    goto fail;    
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
	count = __arraySize(exceptFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9086
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9087
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9088
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9089
	    fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9090
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9091
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9092
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9093
			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
  9094
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9095
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9096
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9097
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9098
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9099
		    if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9100
			FD_SET(f, &eset);       
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9101
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9102
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9103
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9104
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9105
			    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
  9106
			}
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
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9109
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9110
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9111
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9112
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9113
    t = __intVal(millis);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9114
    if (t) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9115
	wt.tv_sec = t / 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9116
	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
  9117
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9118
	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
  9119
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9120
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9121
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9122
     * 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
  9123
     * 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
  9124
     */
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9125
    __BEGIN_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9126
    errno = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9127
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9128
    if (t == 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9129
	/* 
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9130
	 * if there is no timeout time, we can stay here interruptable.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9131
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9132
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9133
	    ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9134
	} 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
  9135
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9136
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9137
	    ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9138
	    /* 
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9139
	     * 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
  9140
	     * could otherwise stay in this loop forever ...
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9141
	     * 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
  9142
	     * 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
  9143
	     */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9144
	} 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
  9145
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9146
    __END_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9147
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9148
    if (ret > 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9149
	OBJ *__resultR = __arrayVal(readableResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9150
	OBJ *__resultW = __arrayVal(writableResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9151
	OBJ *__resultE = __arrayVal(exceptionResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9152
	int i;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9153
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9154
	for (i=0; i <= maxF; i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9155
	    if (FD_ISSET(i, &rset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9156
		if (cntR < resultSizeReadable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9157
		    __resultR[cntR] = __MKSMALLINT(i);
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
		cntR++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9160
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9161
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9162
	    if (FD_ISSET(i, &wset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9163
		if (cntW < resultSizeWritable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9164
		    __resultW[cntW] = __MKSMALLINT(i);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9165
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9166
		cntW++;
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
	    if (FD_ISSET(i, &eset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9170
		if (cntE < resultSizeException) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9171
		    __resultE[cntE] = __MKSMALLINT(i);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9172
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9173
		cntE++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9174
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9175
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9176
	/* add a delimiter */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9177
	if (cntR < resultSizeReadable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9178
	    __resultR[cntR] = nil;
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
	if (cntW < resultSizeWritable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9181
	    __resultW[cntW] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9182
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9183
	if (cntE < resultSizeException) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9184
	    __resultE[cntE] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9185
	}
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9186
        
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9187
	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
  9188
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9189
	if (ret < 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9190
	    if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9191
		errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9192
		@global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9193
	    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9194
		if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9195
		    fprintf(stderr, "OS [info]: select errno = %d\n", errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9196
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9197
		@global(LastErrorNumber) = __MKSMALLINT(errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9198
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9199
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9200
	    @global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9201
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9202
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9203
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9204
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9205
     * Return 0 (no filedescriptor ready)
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
    RETURN (__MKSMALLINT(0));
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9208
fail: ;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9209
%}.
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9210
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9211
     timeout argument not integer,
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9212
     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
  9213
     or not supported by OS
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
    ^ self primitiveFailed
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9218
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9219
    "wait for any fd in readFdArray (an Array of integers) to become ready for reading, 
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9220
     writeFdArray to become ready for writing, 
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9221
     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
  9222
     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
  9223
     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
  9224
     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
  9225
     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
  9226
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9227
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9228
    fd_set rset, wset, eset;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9229
    struct timeval wt, et;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9230
    int f, maxF, i, lX, bX;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9231
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9232
    OBJ fd, retFd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9233
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9234
    int count;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9235
    int numFds = 0;
3801
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9236
#ifndef __isArrayLike
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9237
# define __isArrayLike __isArray
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9238
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9240
    if (__isSmallInteger(millis)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9241
	FD_ZERO(&rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9242
	FD_ZERO(&wset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9243
	FD_ZERO(&eset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9244
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9245
	maxF = -1;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9246
	if (__isNonNilObject(readFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9247
	    if (! __isArrayLike(readFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9248
		goto fail;    
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9249
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9250
	    count = __arraySize(readFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9251
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9252
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9253
		fd = __ArrayInstPtr(readFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9254
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9255
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9256
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9257
			    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
  9258
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9259
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9260
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9261
			if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9262
			    FD_SET(f, &rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9263
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9264
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9265
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9266
			    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9267
				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
  9268
			    }
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
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9272
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9273
	}
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 (__isNonNilObject(writeFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9276
	    if (! __isArrayLike(writeFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9277
		goto fail;    
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9278
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9279
	    count = __arraySize(writeFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9280
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9281
		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9282
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9283
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9284
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9285
			    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
  9286
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9287
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9288
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9289
			if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9290
			    FD_SET(f, &wset);       
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9291
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9292
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9293
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9294
			    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9295
				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
  9296
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9297
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9298
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9299
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9300
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9301
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9302
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9303
	if (__isNonNilObject(exceptFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9304
	    if (! __isArrayLike(exceptFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9305
		goto fail;    
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9306
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9307
	    count = __arraySize(exceptFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9308
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9309
		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9310
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9311
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9312
			if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9313
			    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
  9314
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9315
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9316
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9317
			if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9318
			    FD_SET(f, &eset);       
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9319
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9320
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9321
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9322
			    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9323
				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
  9324
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9325
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9326
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9327
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9328
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9329
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9330
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9331
	t = __intVal(millis);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9332
	if (t) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9333
	    wt.tv_sec = t / 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9334
	    wt.tv_usec = (t % 1000) * 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9335
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9336
	    wt.tv_sec = wt.tv_usec = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9337
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9338
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
	 * make certain, that interrupt gets us out of the select
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9341
	 * However, we must then care for moved objects.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9342
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9343
	__BEGIN_INTERRUPTABLE__
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9344
	errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9345
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9346
	if (t == 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9347
	    /* 
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9348
	     * if there is no timeout time, we can stay here interruptable.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9349
	     */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9350
	    do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9351
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9352
	    } while ((ret < 0) && (errno == EINTR));
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9353
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9354
	    do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9355
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9356
		/* 
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9357
		 * 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
  9358
		 * could otherwise stay in this loop forever ...
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9359
		 * 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
  9360
		 * 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
  9361
		 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9362
	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
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
	__END_INTERRUPTABLE__
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
	if (ret > 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9367
	    for (i=0; i <= maxF; i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9368
		if (FD_ISSET(i, &rset)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9369
		 || FD_ISSET(i, &wset)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9370
		 || FD_ISSET(i, &eset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9371
		    RETURN ( __MKSMALLINT(i) );
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9372
		}
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
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9375
	    if (ret < 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9376
		if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9377
		    errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9378
		    @global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9379
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9380
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9381
			fprintf(stderr, "OS [info]: select errno = %d\n", errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9382
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9383
		    @global(LastErrorNumber) = __MKSMALLINT(errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9384
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9385
	    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9386
		@global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9387
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9388
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9389
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9390
	/*
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9391
	 * Return nil (means time expired or interrupted)
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
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9394
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9395
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9396
fail: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9397
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9398
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9399
     timeout argument not integer,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9400
     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
  9401
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9402
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9403
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9404
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9405
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9406
setBlocking:aBoolean on:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9407
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9408
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9409
    "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
  9410
     a read on the fileDescriptor will block until data is available.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9411
     If cleared, a read operation will immediately return with a value of
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9412
     nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9413
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9414
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9415
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9416
    int ret, flags;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9417
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9418
#if defined(F_GETFL) && defined(F_SETFL)
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9419
# undef DELAY_FLAG
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9420
# if defined(O_NDELAY)
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9421
#  define DELAY_FLAG O_NDELAY
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9422
# elif defined(FNDELAY)
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9423
#  define DELAY_FLAG FNDELAY
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9424
# endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9425
# if defined(DELAY_FLAG)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9426
    if (__isSmallInteger(fd)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9427
	int f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9428
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9429
	flags = fcntl(f, F_GETFL, 0);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9430
	if (aBoolean == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9431
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9432
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9433
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
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
	if (ret >= 0) { 
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9436
	    RETURN ((flags & DELAY_FLAG) ? false : true );
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9437
	}
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9438
    }
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9439
#  undef DELAY_FLAG
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9440
# endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9441
#endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9442
%}.
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9443
    "
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9444
     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
  9445
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9446
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9447
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9448
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9449
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9450
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9451
update:aspect with:argument from:anObject
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9452
    "one of our registered handles has been collected"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9453
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9454
    aspect == #ElementExpired ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9455
	OpenFiles keysAndValuesDo:[:fd :handle |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9456
	    handle == 0 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9457
		"Have to close the file descriptor"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9458
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9459
		OperatingSystem closeFd:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9460
		OpenFiles at:fd put:nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9461
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9462
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9463
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9464
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9465
    "Created: 30.9.1997 / 12:57:35 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9466
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9467
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9468
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9469
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9470
initialize
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9471
     OpenFiles := WeakArray new:10.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9472
     OpenFiles addDependent:self. 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9473
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9474
     "self initialize"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9475
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9476
    "Created: 26.9.1997 / 17:15:50 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9477
    "Modified: 30.9.1997 / 12:40:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9478
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9479
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9480
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9481
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9482
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9483
    "create an instance of myself for a given fileDescriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9484
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9485
    ^ self new for:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9486
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9487
    "Created: 30.9.1997 / 14:00:00 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9488
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9489
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9490
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9491
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9492
error:anErrorSymbolOrErrno
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9493
    "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
  9494
     or the error number as returned by the OperatingSystem"
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9495
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9496
    anErrorSymbolOrErrno isInteger ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9497
	(UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9498
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9499
    self primitiveFailed:anErrorSymbolOrErrno.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9500
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9501
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9502
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9503
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9504
close
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9505
    "close the descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9506
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9507
    |desc|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9508
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9509
    desc := fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9510
    self invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9511
    ^ OperatingSystem closeFd:desc.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9512
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9513
    "Modified: 30.9.1997 / 13:06:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9514
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9515
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9516
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9517
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9518
for:aFileDescriptor
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9519
    "create a file for a handle"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9520
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9521
    |oldHandle|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9522
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9523
    fd := aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9524
    oldHandle := OpenFiles at:aFileDescriptor.
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9525
    "/ 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
  9526
    "/ 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
  9527
    (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
  9528
	oldHandle invalidate.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9529
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9530
    self register.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9531
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9532
    "Created: 26.9.1997 / 17:14:40 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9533
    "Modified: 30.9.1997 / 12:41:43 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9534
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9535
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9536
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9537
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9538
readBytes:count into:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9539
    "read count bytes into a byte-buffer;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9540
     Return the number of bytes read.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9541
     The read is non-blocking. If the operation would block
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9542
     either an incomplete count or nil will be returned.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9543
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9544
     An exception is raised on any other error"
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9545
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9546
    |error|
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9547
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9548
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9549
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9550
    int nRead = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9551
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9552
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9553
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9554
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9555
    if (! __isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9556
	error = @symbol(errorNotOpen);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9557
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9558
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9559
    if (! __bothSmallInteger(count, firstIndex)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9560
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9561
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9562
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9563
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9564
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9565
    offs = __smallIntegerVal(firstIndex) - 1;
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
    if (fd < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9568
	error = @symbol(internalError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9569
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
  9570
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
  9571
    if (__isExternalBytesLike(aByteBuffer)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9572
	OBJ sz;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9573
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9574
	nInstBytes = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9575
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9576
	sz = __externalBytesSize(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9577
	if (__isSmallInteger(sz)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9578
	    objSize = __smallIntegerVal(sz);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9579
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9580
	    objSize = -1; /* unknown */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9581
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9582
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9583
	OBJ oClass;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9584
	int nInstVars;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9585
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9586
	oClass = __Class(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9587
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9588
	    case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9589
	    case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9590
	    case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9591
	    case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9592
	    case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9593
	    case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9594
	    case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9595
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9596
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9597
		error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9598
		goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9599
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9600
	extPtr = (char *)0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9601
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9602
	nInstBytes = __OBJS2BYTES__(nInstVars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9603
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9604
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9605
    if ((offs >= 0)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9606
	&& (cnt >= 0)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9607
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9608
	nRead = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9609
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9610
	do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9611
	    int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9612
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9613
	    if (extPtr) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9614
		n = read(fd, extPtr+offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9615
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9616
		char *bp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9617
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9618
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9619
		 * on interrupt, anObject may be moved to another location.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9620
		 * So we recompute the byte-address here.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9621
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9622
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9623
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9624
		n = read(fd, bp + offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9625
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9626
	    if (n > 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9627
		cnt -= n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9628
		offs += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9629
		nRead += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9630
	    } else if (n == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9631
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9632
	    } else if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9633
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9634
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9635
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9636
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9637
#ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9638
		    || errno == EAGAIN
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9639
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9640
		) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9641
		     RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9642
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9643
		if (errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9644
		     error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9645
		     goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9646
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9647
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9648
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9649
	} while (cnt > 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9650
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9651
	RETURN (__mkSmallInteger(nRead));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9652
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9653
bad: ;   
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9654
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9655
    ^ self error:error.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9656
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9657
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9658
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9659
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9660
     h := OperatingSystem openFileForRead:'/etc/hosts'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9661
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9662
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9663
     Transcript show:n; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9664
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9665
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9666
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9667
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9668
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9669
     h := OperatingSystem openFileForRead:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9670
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9671
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9672
     Transcript show:n printString; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9673
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9674
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9675
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9676
writeBytes:count from:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9677
    "write count bytes from a byte-buffer;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9678
     Return the number of bytes written (negative on error)"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9679
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9680
    |error|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9681
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9682
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9683
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9684
    int nWritten = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9685
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9686
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9687
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9688
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9689
    if (! __isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9690
	error = @symbol(errorNotOpen);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9691
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9692
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9693
    if (! __bothSmallInteger(count, firstIndex)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9694
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9695
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9696
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9697
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9698
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9699
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9700
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9701
    if (fd < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9702
	error = @symbol(internalError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9703
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
  9704
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
  9705
    if (__isExternalBytesLike(aByteBuffer)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9706
	OBJ sz;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9707
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9708
	nInstBytes = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9709
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9710
	sz = __externalBytesSize(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9711
	if (__isSmallInteger(sz)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9712
	    objSize = __smallIntegerVal(sz);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9713
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9714
	    objSize = -1; /* unknown */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9715
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9716
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9717
	OBJ oClass;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9718
	int nInstVars;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9719
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9720
	oClass = __Class(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9721
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9722
	    case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9723
	    case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9724
	    case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9725
	    case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9726
	    case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9727
	    case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9728
	    case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9729
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9730
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9731
		error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9732
		goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9733
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9734
	extPtr = (char *)0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9735
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9736
	nInstBytes = __OBJS2BYTES__(nInstVars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9737
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9738
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9739
    if ((offs >= 0)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9740
	&& (cnt >= 0)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9741
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9742
	nWritten = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9743
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9744
	do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9745
	    int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9746
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9747
	    if (extPtr) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9748
		n = write(fd, extPtr+offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9749
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9750
		char *bp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9751
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9752
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9753
		 * on interrupt, anObject may be moved to another location.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9754
		 * So we recompute the byte-address here.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9755
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9756
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9757
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9758
		n = write(fd, bp + offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9759
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9760
	    if (n > 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9761
		cnt -= n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9762
		offs += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9763
		nWritten += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9764
	    } else if (n == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9765
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9766
	    } else if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9767
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9768
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9769
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9770
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9771
#ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9772
		    || errno == EAGAIN
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9773
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9774
		) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9775
		     RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9776
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9777
		if (errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9778
		     error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9779
		     goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9780
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9781
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9782
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9783
	} while (cnt > 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9784
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9785
	RETURN (__mkSmallInteger(nWritten));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9786
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9787
bad: ;   
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9788
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9789
    ^ self error:error
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9790
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9791
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9792
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9793
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9794
     h := OperatingSystem createFileForReadWrite:'/tmp/xx'.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9795
     buff := '12345678901234567890'.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9796
     n := h writeBytes:10 from:buff startingAt:1.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9797
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9798
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9799
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9800
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9801
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9802
     h := OperatingSystem createFileForReadWrite:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9803
     buff := '12345678901234567890'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9804
     n := h writeBytes:10 from:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9805
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9806
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9807
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9808
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9809
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9810
nextError
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9811
    "retrieve the pending error from the current fileDescriptor
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9812
     and raise an error exception.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9813
     This should be only called, when an error is pending.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9814
     Otherwise a byte may be lost"
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9815
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9816
    |dummyByte|
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9817
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9818
    dummyByte := ByteArray new:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9819
    ^ self readBytes:1 into:dummyByte startingAt:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9820
!
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
  9821
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9822
seekTo:newPosition from:whence
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9823
    "seek to newPosition
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9824
     whence is one of: #begin #current #end.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9825
     Return the new position.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9826
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9827
     TODO: 64 bit handling"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9828
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9829
    |error|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9830
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9831
%{
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9832
    INT fd, pos, ret;
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9833
    INT __whence;
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9834
    __uint64__ pos64;
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9835
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9836
    if (! __isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9837
	error = @symbol(errorNotOpen);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9838
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9839
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9840
    if (__isSmallInteger(newPosition)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9841
	pos = __smallIntegerVal(newPosition);
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9842
    } else if (__signedLong64IntVal(newPosition, &pos64) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9843
	error = @symbol(badArgument1);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9844
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9845
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9846
    fd = __smallIntegerVal(__INST(fd));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9847
    if (fd < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9848
	error = @symbol(internalError);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9849
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9850
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9851
    if (whence == @symbol(begin)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9852
	__whence = SEEK_SET;    
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9853
    } else if (whence == @symbol(current)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9854
	__whence = SEEK_CUR;    
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9855
    } else if (whence == @symbol(end)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9856
	__whence = SEEK_END;    
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9857
    } else {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9858
	error = @symbol(badArgument2);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9859
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9860
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9861
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9862
again:
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9863
    ret = lseek(fd, pos, __whence);
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9864
    if (ret < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9865
	if (errno == EINTR) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9866
	    __HANDLE_INTERRUPTS__;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9867
	    goto again;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9868
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9869
	error = __mkSmallInteger(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9870
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9871
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9872
    /* RETURN (__mkInteger(ret)); */
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9873
    RETURN (__mkSmallInteger(ret));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9874
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9875
bad: ;   
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9876
%}.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9877
    ^ self error:error.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9878
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9879
    "
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9880
     |h buff n|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9881
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9882
     h := OperatingSystem openFileForRead:'/etc/hosts'.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9883
     h seekTo:10 from:#begin.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9884
     buff := ByteArray new:1000. buff inspect.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9885
     n := h readBytes:1000 into:buff startingAt:1.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9886
     Transcript show:n; space; showCR:buff asString.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  9887
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9888
!
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
selectWithTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9891
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9892
     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
  9893
     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
  9894
     of read-data.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9895
     Experimental."
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
    ^ OperatingSystem selectOnAnyReadable:(Array with:fd)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9898
		      writable:(Array with:fd)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9899
		     exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9900
		   withTimeOut:millis
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9901
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9902
    "Created: 1.10.1997 / 08:51:11 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9903
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9904
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9905
setBlocking:aBoolean
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9906
    "{ Pragma: +optSpace }"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9907
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9908
    "set/clear the blocking attribute - if set (which is the default)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9909
     a read on the fileDescriptor will block until data is available.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9910
     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
  9911
     nil if no data is available."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9912
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9913
    |err|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9914
%{  
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9915
    int ret, flags;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9916
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9917
#if defined(F_GETFL) && defined(F_SETFL)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9918
# if defined(O_NDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9919
#  define DELAY O_NDELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9920
# else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9921
#  if defined(FNDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9922
#   define DELAY FNDELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9923
#  endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9924
# endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9925
# if defined(DELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9926
    if (__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9927
	int f = __intVal(__INST(fd));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9928
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9929
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9930
	if (aBoolean == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9931
	    ret = fcntl(f, F_SETFL, flags & ~DELAY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9932
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9933
	    ret = fcntl(f, F_SETFL, flags | DELAY);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9934
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9935
	if (ret >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9936
	    RETURN(__MKSMALLINT(flags)); 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9937
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9938
	    err = __MKSMALLINT(errno);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9939
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9940
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9941
# undef DELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9942
# endif /* DELAY */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9943
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9944
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9945
    err notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9946
	self error:err
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9947
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9948
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9949
     fd argument not integer
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9950
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9951
    ^ self primitiveFailed
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9952
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9953
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9954
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9955
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
  9956
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'private-accessing'!
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9957
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9958
fileDescriptor
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9959
    "return the (integer) fileDescriptor"
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9960
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9961
%{
7462
05b5202d988a Fix compiler warning
Stefan Vogel <sv@exept.de>
parents: 7461
diff changeset
  9962
    OBJ handle = __externalAddressVal(self);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9963
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9964
    if (__isSmallInteger(handle)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9965
	RETURN (handle);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9966
    }
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9967
%}.
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9968
    ^ nil
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9969
!
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9970
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9971
setFileDescriptor:anInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9972
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9973
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9974
    if (__isSmallInteger(anInteger)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9975
	__externalAddressVal(self) = (OBJ)(__smallIntegerVal(anInteger));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9976
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9977
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9978
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9979
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9980
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9981
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9982
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9983
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9984
canReadWithoutBlocking
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9985
    "return true, if data is available on a filedescriptor 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9986
     (i.e. read is possible without blocking).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9987
     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
  9988
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9989
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9990
    int fd;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9991
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9992
    if (__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9993
	fd = __smallIntegerVal(__INST(fd));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9994
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9995
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9996
	 * if available, try FIONREAD first, which is usually done faster.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9997
	 */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9998
# ifdef FIONREAD
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9999
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10000
	    int result = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10001
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10002
	    if (ioctl(fd, FIONREAD, &result) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10003
		RETURN(result > 0 ? true : false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10004
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10005
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10006
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10007
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10008
# if defined(__VMS__) && defined(DOES_NOT_WORK_YET)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10009
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10010
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10011
	     * do a sys$qio ..
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10012
	     * fd here is suposed to be a channel nr.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10013
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10014
	    struct IOSB iosb;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10015
	    int status;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10016
	    int channel;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10017
	    struct typahdask sensebuf;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10018
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10019
	    status = SYS$QIO(0, /* efn */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10020
			     fd,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10021
			     IO$_SENSEMODE | IO$M_TYPEAHDCNT,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10022
			     &iosb,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10023
			     0, /* ast */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10024
			     0, /* ast arg */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10025
			     &sensebuf,         /* data */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10026
			     sizeof(sensebuf),  /* data size */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10027
			     0, 0, 0, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10028
	    if (status != SS$_NORMAL) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10029
		fprintf(stderr, "OS [info]: SYS$QIO failed on %d\n", fd);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10030
	    } else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10031
		fprintf(stderr, "sys$QIO -> %d\n", sensebuf.typcnt);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10032
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10033
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10034
# endif /* __VMS__ */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10035
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10036
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10037
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10038
    OperatingSystem supportsSelect ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10039
	"/ mhmh - what should we do then ?
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10040
	"/ For now, return true as if data was present,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10041
	"/ and let the thread fall into the read.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10042
	"/ It will then (hopefully) be desceduled there and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10043
	"/ effectively polling for input.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10044
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10045
	^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10046
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10047
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10048
    ^ (OperatingSystem selectOnAnyReadable:(Array with:fd)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10049
		       writable:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10050
		       exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10051
		       withTimeOut:0) == fd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10052
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10053
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10054
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10055
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10056
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10057
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10058
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10059
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10060
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10061
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10062
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10063
     h := OperatingSystem openFileForRead:'/dev/ttyS0'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10064
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10065
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10066
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10067
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10068
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10069
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10070
canWriteWithoutBlocking
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10071
    "return true, if filedescriptor can be written without blocking"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10072
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10073
    OperatingSystem supportsSelect ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10074
	"/ mhmh - what should we do then ?
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10075
	"/ For now, return true as if data was present,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10076
	"/ and let the thread fall into the write.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10077
	"/ It will then (hopefully) be desceduled there and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10078
	"/ effectively polling for output.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10079
	^ true
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10080
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10081
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10082
    ^ (OperatingSystem selectOnAnyReadable:nil
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10083
		       writable:(Array with:fd)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10084
		       exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10085
		       withTimeOut:0) == fd
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10086
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10087
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10088
isValid
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10089
    "answer true, if the handle is valid, i.e. connected to
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10090
     a file or some other OS object"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10091
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10092
    ^ fd notNil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10093
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10094
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10095
numAvailableForRead
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10096
    "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
 10097
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
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10100
     * 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
 10101
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10102
# if defined(FIONREAD)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10103
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10104
	int n = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10105
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10106
	if (__isSmallInteger(__INST(fd))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10107
	    if (ioctl(__smallIntegerVal(__INST(fd)), FIONREAD, &n) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10108
		RETURN (__MKINT(n));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10109
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10110
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10111
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10112
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10113
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10114
    ^ self canReadWithoutBlocking ifTrue:[1] ifFalse:[0]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10115
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10116
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10117
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10118
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10119
     n := h numAvailableForRead.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10120
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10121
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10122
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10123
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10124
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10125
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10126
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10127
register
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10128
    "register myself as an open file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10129
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10130
    |sz old|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10131
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10132
    sz := OpenFiles size.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10133
    fd > sz ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10134
	"grow for more descriptors"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10135
	old := OpenFiles.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10136
	OpenFiles := WeakArray new:(sz * 2).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10137
	old removeDependent:(self class).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10138
	OpenFiles addDependent:(self class).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10139
	old keysAndValuesDo:[:index :elem|
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10140
	    "be careful to not overwrite new entries in OpenFiles"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10141
	    elem notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10142
		OpenFiles at:index put:elem.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10143
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10144
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10145
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10146
    OpenFiles at:fd put:self.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10147
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10148
    "Created: 30.9.1997 / 12:51:48 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10149
    "Modified: 30.9.1997 / 12:58:37 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10150
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10151
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10152
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10153
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10154
invalidate
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10155
    "a file handle has become invalid"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10156
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10157
    OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10158
    fd := nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10159
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10160
    "Created: 30.9.1997 / 12:37:26 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10161
    "Modified: 30.9.1997 / 12:42:16 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10162
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10163
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10164
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10165
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10166
readWaitWithTimeoutMs:timeout 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10167
    "suspend the current process, until the receiver
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10168
     becomes ready for reading or a timeout (in milliseconds) expired. 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10169
     If data is already available, return immediate. 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10170
     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
 10171
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10172
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10173
    |inputSema hasData wasBlocked|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10174
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10175
    fd isNil ifTrue:[^ self error:#errorNotOpen].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10176
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10177
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10178
    hasData := self canReadWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10179
    hasData ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10180
	inputSema := Semaphore new name:'readWait'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10181
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10182
	    timeout notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10183
		Processor signal:inputSema afterMilliseconds:timeout 
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10184
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10185
	    Processor signal:inputSema onInput:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10186
	    Processor activeProcess state:#ioWait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10187
	    inputSema wait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10188
	    Processor disableSemaphore:inputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10189
	    hasData := self canReadWithoutBlocking.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10190
	] ifCurtailed:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10191
	    Processor disableSemaphore:inputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10192
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10193
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10194
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10195
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10196
    ^ hasData not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10197
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10198
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10199
writeWaitWithTimeoutMs:timeout
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10200
    "suspend the current process, until the receiver
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10201
     becomes ready for writing or a timeout (in seconds) expired. 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10202
     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
 10203
     Return immediate if the receiver is already ready. 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10204
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10205
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
 10206
    |outputSema canWrite wasBlocked|
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10207
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10208
    fd isNil ifTrue:[^ self error:#errorNotOpen].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10209
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10210
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10211
    canWrite := self canWriteWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10212
    canWrite ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10213
	outputSema := Semaphore new name:'writeWait'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10214
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10215
	    timeout notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10216
		Processor signal:outputSema afterMilliseconds:timeout
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10217
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10218
	    Processor signal:outputSema onOutput:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10219
	    Processor activeProcess state:#ioWait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10220
	    outputSema wait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10221
	    Processor disableSemaphore:outputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10222
	    canWrite := self canWriteWithoutBlocking.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10223
	] ifCurtailed:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10224
	    Processor disableSemaphore:outputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10225
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10226
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10227
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10228
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10229
    ^ canWrite not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10230
! !
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10231
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10232
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
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
closeFile
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10235
    "close the underlying 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
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10238
    FILE *f = (FILE *)(__externalAddressVal(self));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10239
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10240
    if (f) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10241
	__externalAddressVal(self) = NULL;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10242
	fclose(f);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10243
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10244
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10245
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10246
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10247
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10248
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10249
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10250
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
 10251
    ^ self basicNew
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10252
	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
 10253
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10254
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10255
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10256
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10257
accessTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10258
    "return accessed"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10259
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10260
    accessed isInteger ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10261
	"/ lazy time conversion
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10262
	accessed := AbsoluteTime fromOSTime:(accessed * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10263
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10264
    ^ accessed
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10265
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10266
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10267
alternativeName
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10268
    "return the files other name (DOS name on windows).
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10269
     Nil if there is no other name"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10270
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10271
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10272
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10273
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10274
creationTime
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10275
    ^ nil
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10276
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10277
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10278
fileSize
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10279
    "return size"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10280
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10281
    ^ size
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10282
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10283
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10284
fixedHeaderSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10285
    "return the fixedHeaderSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10286
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10287
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10288
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10289
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10290
gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10291
    "return gid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10292
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10293
    ^ gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10294
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10295
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10296
id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10297
    "return id"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10298
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10299
    ^ id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10300
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10301
6796
edbaaeaa2ba0 additional queries for FileInfo
penk
parents: 6792
diff changeset
 10302
isDirectory
edbaaeaa2ba0 additional queries for FileInfo
penk
parents: 6792
diff changeset
 10303
    ^ type == #directory
edbaaeaa2ba0 additional queries for FileInfo
penk
parents: 6792
diff changeset
 10304
!
edbaaeaa2ba0 additional queries for FileInfo
penk
parents: 6792
diff changeset
 10305
edbaaeaa2ba0 additional queries for FileInfo
penk
parents: 6792
diff changeset
 10306
isSymbolicLink
edbaaeaa2ba0 additional queries for FileInfo
penk
parents: 6792
diff changeset
 10307
    ^ type == #symbolicLink
edbaaeaa2ba0 additional queries for FileInfo
penk
parents: 6792
diff changeset
 10308
!
edbaaeaa2ba0 additional queries for FileInfo
penk
parents: 6792
diff changeset
 10309
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10310
mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10311
    "return mode"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10312
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10313
    ^ mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10314
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10315
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10316
modificationTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10317
    "return modified"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10318
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10319
    modified isInteger ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10320
	"/ lazy time conversion
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10321
	modified := AbsoluteTime fromOSTime:(modified * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10322
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10323
    ^ modified
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10324
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10325
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10326
numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10327
    "return numLinks"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10328
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10329
    ^ numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10330
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10331
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10332
path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10333
    "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
 10334
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10335
    ^ path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10336
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10337
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10338
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10339
recordAttributes
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10340
    "return the recordAttributes (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10341
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10342
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10343
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10344
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10345
recordFormat
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10346
    "return the recordFormat (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10347
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10348
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10349
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10350
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10351
recordFormatNumeric
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10352
    "return the recordFormat as numeric (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10353
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10354
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10355
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10356
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10357
recordSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10358
    "return the recordSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10359
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10360
    ^ nil
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
6372
9cd3ac764491 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6371
diff changeset
 10363
statusChangeTime
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10364
    statusChanged isInteger ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10365
	"/ lazy time conversion
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10366
	statusChanged := AbsoluteTime fromOSTime:(statusChanged * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10367
    ].
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10368
    ^ statusChanged
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10369
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10370
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10371
type
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10372
    "return type"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10373
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10374
    ^ type
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10375
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10376
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10377
uid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10378
    "return uid"
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
    ^ uid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10381
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10382
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10383
!UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10384
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10385
accessed
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10386
    "return accessed"
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10387
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10388
    self obsoleteMethodWarning:'use #accessTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10389
    ^ self accessTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10390
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10391
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10392
at:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10393
    "backward compatibility access: in previous releases, IdentityDictionaries
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10394
     were used to hold my information. Allow access via key messages.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10395
     This method will vanish - use the proper access protocol."
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
    ^ self perform:key
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10398
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10399
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10400
modified
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10401
    "return modified"
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10402
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10403
    self obsoleteMethodWarning:'use #modificationTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10404
    ^ self modificationTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10405
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10406
6801
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10407
size
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10408
    "return size"
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10409
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10410
    ^ size
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10411
!
0e566d6fe76e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6797
diff changeset
 10412
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10413
statusChanged
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10414
    "return statusChanged"
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10415
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10416
    self obsoleteMethodWarning:'use #statusChangeTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10417
    ^ self statusChangeTime
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10418
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10419
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 10420
!UnixOperatingSystem::FileStatusInfo methodsFor:'private-accessing'!
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10421
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10422
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
 10423
    type := t.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10424
    mode := m.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10425
    uid := u.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10426
    gid := g.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10427
    size := s.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10428
    id := i.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10429
    accessed := aT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10430
    modified := mT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10431
    statusChanged := sT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10432
    path := lP.
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10433
    numLinks := nL.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10434
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10435
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10436
!UnixOperatingSystem::MountInfo methodsFor:'accessing'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10437
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10438
mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10439
    "return the value of the instance variable 'mountPointPath' (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10440
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10441
    ^ mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10442
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10443
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10444
mountPointPath:mountPointArg deviceOrRemotePath:deviceOrRemotePathArg fsType:fsTypeArg attributeString:attributeStringArg 
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10445
    "set instance variables (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10446
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10447
    mountPointPath := mountPointArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10448
    deviceOrRemotePath := deviceOrRemotePathArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10449
    fsType := fsTypeArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10450
    attributeString := attributeStringArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10451
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10452
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10453
!UnixOperatingSystem::MountInfo methodsFor:'queries'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10454
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10455
isRemote
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10456
    ^ fsType = 'nfs'
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10457
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10458
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10459
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10460
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10461
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10462
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10463
    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
 10464
    operating system processes (these are no smalltalk processes!!).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10465
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10466
    [Instance variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10467
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10468
	pid     <Integer>       OS-Process identifier
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10469
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10470
	status  <Symbol>        either #exit #signal #stop #continue
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10471
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10472
	code    <Integer>       either exitcode or signalnumber
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10473
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10474
	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
 10475
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10476
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10477
    [author:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10478
	Stefan Vogel
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10479
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10480
    [see also:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10481
	OperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10482
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10483
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10484
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10485
!UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10486
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10487
pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10488
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10489
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10490
    ^ 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
 10491
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10492
    "Created: 28.12.1995 / 14:16:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10493
    "Modified: 30.4.1996 / 18:25:00 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10494
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10495
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10496
processCreationFailure
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10497
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10498
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10499
    ^ 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
 10500
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10501
    "Created: 28.12.1995 / 14:35:29 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10502
    "Modified: 30.4.1996 / 18:25:05 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10503
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10504
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10505
!UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10506
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10507
code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10508
    "return the exitcode / signalNumber"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10509
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10510
    ^ code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10511
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10512
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10513
    "Modified: 30.4.1996 / 18:26:23 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10514
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10515
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10516
core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10517
    "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
 10518
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10519
    ^ core == true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10520
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10521
    "Modified: 28.12.1995 / 14:14:38 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10522
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10523
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10524
pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10525
    "return the pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10526
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10527
    ^ pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10528
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10529
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10530
    "Modified: 30.4.1996 / 18:26:30 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10531
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10532
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10533
status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10534
    "return status as a Symbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10535
     one of #exit #signal #stop #continue"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10536
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10537
    ^ status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10538
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10539
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10540
    "Modified: 30.4.1996 / 18:26:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10541
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10542
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10543
!UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10544
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10545
pid:newPid status:newStatus code:newCode core:newCore
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10546
    pid := newPid.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10547
    status := newStatus.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10548
    code := newCode.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10549
    core := newCore.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10550
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10551
    "Created: 28.12.1995 / 14:18:22 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10552
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10553
7175
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10554
!UnixOperatingSystem::OSProcessStatus methodsFor:'printing & storing'!
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10555
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10556
printOn:aStream
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10557
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10558
    aStream nextPutAll:'ExitStatus ('.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10559
    status printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10560
    aStream nextPutAll:', code='.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10561
    code printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10562
    aStream nextPut:$).
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10563
! !
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 10564
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10565
!UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10566
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10567
code:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10568
    "set the exitCode"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10569
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10570
    code := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10571
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10572
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10573
    "Modified: 30.4.1996 / 18:25:18 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10574
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10575
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10576
core:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10577
    "set core"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10578
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10579
    core := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10580
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10581
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10582
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10583
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10584
pid:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10585
    "set pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10587
    pid := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10588
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10589
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10590
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10591
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10592
status:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10593
    "set status"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10594
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10595
    status := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10596
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10597
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10598
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10599
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10600
!UnixOperatingSystem::OSProcessStatus methodsFor:'queries'!
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
couldNotExecute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10603
    "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
 10604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10605
    ^ status == #exit and:[code = 127].
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
    "Created: 28.12.1995 / 15:43:17 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10608
    "Modified: 30.4.1996 / 18:27:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10609
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10610
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10611
stillAlive
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10612
    "true if process is still alive"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10613
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10614
    ^ status == #stop or:[status == #continue]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10615
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10616
    "Created: 28.12.1995 / 14:27:26 / stefan"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10619
success
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10620
    "true if process terminated successfully"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10621
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10622
    ^ status == #exit and:[code = 0]
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
    "Created: 28.12.1995 / 14:13:05 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10625
    "Modified: 28.12.1995 / 14:13:41 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10626
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10627
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10628
!UnixOperatingSystem::SocketHandle class methodsFor:'constants'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10629
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10630
protocolCodeOf:aNameOrNumber
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10631
    "convert a symbol to a numeric protocol code"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10632
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10633
    |protocolCode protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10634
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10635
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10636
    if (__isSmallInteger(aNameOrNumber) || aNameOrNumber == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10637
	RETURN(aNameOrNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10638
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10639
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10640
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10641
    ProtocolCache notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10642
	protocolCode := ProtocolCache at:(aNameOrNumber asSymbol) ifAbsent:[].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10643
	protocolCode notNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10644
	    ^ protocolCode.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10645
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10646
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10647
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10648
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10649
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10650
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10651
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10652
    if (__isString(aNameOrNumber) || __isSymbol(aNameOrNumber)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10653
	protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10654
	if (protoent) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10655
	    protocolCode = __MKSMALLINT(protoent->p_proto);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10656
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10657
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10658
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10659
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10660
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10661
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10662
    protocolSymbol notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10663
	ProtocolCache isNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10664
	    ProtocolCache := IdentityDictionary new.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10665
	].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10666
	"beware of polluting the protocol cache with aliases"
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10667
	ProtocolCache at:protocolSymbol put:protocolCode.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10668
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10669
    ^ protocolCode
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10670
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10671
    "
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10672
     self protocolCodeOf:#tcp     
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10673
     self protocolCodeOf:#udp     
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10674
     self protocolCodeOf:#raw     
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10675
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10676
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10677
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10678
protocolSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10679
    "convert a numeric protocol code to a symbol"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10680
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10681
    |protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10682
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10683
    ProtocolCache notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10684
	protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger ifAbsent:[].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10685
	protocolSymbol notNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10686
	    ^ protocolSymbol.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10687
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10688
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10689
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10690
%{ 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10691
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10692
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10693
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10694
    if (__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10695
	protoent = getprotobynumber(__intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10696
	if (protoent) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10697
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10698
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10699
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10700
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10701
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10702
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10703
    protocolSymbol notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10704
	ProtocolCache isNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10705
	    ProtocolCache := IdentityDictionary new.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10706
	].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10707
	ProtocolCache at:protocolSymbol put:anInteger.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10708
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10709
    ^ protocolSymbol
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10710
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10711
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10712
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10713
     self protocolSymbolOf:(self protocolCodeOf:#tcp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10714
     self protocolSymbolOf:(self protocolCodeOf:#udp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10715
     self protocolSymbolOf:(self protocolCodeOf:#icmp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10716
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10717
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10718
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10719
!UnixOperatingSystem::SocketHandle class methodsFor:'initialization'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10720
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10721
reinitialize
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10722
    "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
 10723
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10724
    ProtocolCache := nil.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10725
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10726
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10727
!UnixOperatingSystem::SocketHandle class methodsFor:'queries'!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10728
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10729
getAddressInfo:hostName serviceName:serviceName domain:domainArg type:typeArg protocol:protoArg flags:flags 
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10730
    "answer an Array of socket addresses for serviceName on hostName
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10731
     Domain, type, protocol may be nil or specify a hint for the socket 
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10732
     addresses to be returned."
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10733
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10734
    |error errorString result domain type proto|
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10735
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 10736
    domain := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 10737
    type := OperatingSystem socketTypeCodeOf:typeArg.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10738
    proto := self protocolCodeOf:protoArg.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10739
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10740
%{ /* STACK:32000 */
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 10741
#undef xxAI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10742
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10743
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10744
#if !defined(NO_SOCKET) 
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10745
    char *__hostName, *__serviceName;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10746
    int ret, cnt = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10747
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10748
    if (hostName == nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10749
	__hostName = 0;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10750
    } else if (__isString(hostName) || __isSymbol(hostName)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10751
	__hostName = __stringVal(hostName);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10752
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10753
	error = @symbol(badArgument1);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10754
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10755
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10756
    if (serviceName == nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10757
	__serviceName = 0;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10758
    } else if (__isString(serviceName) || __isSymbol(serviceName)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10759
	__serviceName = __stringVal(serviceName);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10760
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10761
	error = @symbol(badArgument2);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10762
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10763
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10764
    if (__hostName == 0 && __serviceName == 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10765
	error = @symbol(badArgument);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10766
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10767
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10768
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10769
{
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10770
# if defined(AI_NUMERICHOST)
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10771
    /*  
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10772
     * Use getaddrinfo()
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10773
     */
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10774
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10775
    struct addrinfo hints;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10776
    struct addrinfo *info = 0, *infop;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10777
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10778
    memset(&hints, 0, sizeof(hints));
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10779
    if (__isSmallInteger(domain))
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10780
	hints.ai_family = __intVal(domain);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10781
    if (__isSmallInteger(type))
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10782
	hints.ai_socktype = __intVal(type);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10783
    if (__isSmallInteger(proto))
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10784
	hints.ai_protocol = __intVal(proto);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10785
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10786
    do {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10787
	__BEGIN_INTERRUPTABLE__
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10788
	ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10789
	__END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10790
    } while (ret == EAI_SYSTEM && errno == EINTR);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10791
    if (ret != 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10792
	switch (ret) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10793
	case EAI_FAMILY:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10794
	    error = @symbol(badProtocol);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10795
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10796
	case EAI_SOCKTYPE:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10797
	    error = @symbol(badSocketType);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10798
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10799
	case EAI_BADFLAGS:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10800
	    error = @symbol(badFlags);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10801
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10802
	case EAI_NONAME:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10803
	    error = @symbol(unknownHost);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10804
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10805
	case EAI_SERVICE:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10806
	    error = @symbol(unknownService);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10807
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10808
	case EAI_ADDRFAMILY :
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10809
	    error = @symbol(unknownHostForProtocol);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10810
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10811
	case EAI_NODATA:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10812
	    error = @symbol(noAddress);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10813
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10814
	case EAI_MEMORY:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10815
	    error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10816
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10817
	case EAI_FAIL:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10818
	    error = @symbol(permanentFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10819
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10820
	case EAI_AGAIN:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10821
	    error = @symbol(tryAgain);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10822
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10823
	case EAI_SYSTEM:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10824
	    error = @symbol(systemError);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10825
	    break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10826
	default:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10827
	    error = @symbol(unknownError);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10828
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10829
	errorString = __MKSTRING(gai_strerror(ret));
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10830
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10831
    } 
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10832
    for (cnt=0, infop=info; infop; infop=infop->ai_next)
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10833
	cnt++;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10834
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10835
    result = __ARRAY_NEW_INT(cnt);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10836
    if (result == nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10837
	error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10838
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10839
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10840
    for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10841
	OBJ o, resp;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10842
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10843
	resp = __ARRAY_NEW_INT(6);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10844
	if (resp == nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10845
	    error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10846
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10847
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10848
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10849
	__ArrayInstPtr(result)->a_element[cnt] = resp;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10850
	__STORE(result, resp);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10851
	__ArrayInstPtr(resp)->a_element[0] = __MKSMALLINT(infop->ai_flags);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10852
	__ArrayInstPtr(resp)->a_element[1] = __MKSMALLINT(infop->ai_family);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10853
	__ArrayInstPtr(resp)->a_element[2] = __MKSMALLINT(infop->ai_socktype);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10854
	__ArrayInstPtr(resp)->a_element[3] = __MKSMALLINT(infop->ai_protocol);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10855
	o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);        
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10856
	if (o == nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10857
	    error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10858
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10859
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10860
	memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10861
       __ArrayInstPtr(resp)->a_element[4] = o;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10862
	__STORE(resp, o);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10863
	if (infop->ai_canonname) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10864
	    o = __MKSTRING(infop->ai_canonname);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10865
	    if (o == nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10866
		error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10867
		goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10868
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10869
	    __ArrayInstPtr(resp)->a_element[5] = o;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10870
	    __STORE(resp, o);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10871
	}
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10872
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10873
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10874
err:
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10875
    if (info) freeaddrinfo(info);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10876
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10877
# else /* ! AI_NUMERICHOST =============================================================*/
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10878
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10879
    /*  
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10880
     * Use getservbyname() / gethostByName()
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 10881
     */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10882
    struct hostent *hp;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10883
    char **addrpp;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10884
    int port = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10885
    int i;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10886
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10887
    if (__serviceName) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10888
	struct servent *sp;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10889
	char *__proto = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10890
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10891
	if (__isString(protoArg) || __isSymbol(protoArg))
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10892
	    __proto = __stringVal(protoArg);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10893
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10894
	sp = getservbyname(__serviceName, __proto);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10895
	if (sp == NULL) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10896
	    errorString = @symbol(unknownService);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10897
	    error = __mkSmallInteger(-3);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10898
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10899
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10900
	port = sp->s_port;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10901
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10902
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10903
    if (__hostName) {
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10904
#  ifdef USE_H_ERRNO
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10905
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10906
	    /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10907
	     * uses a static data area
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10908
	     */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10909
	    __BEGIN_INTERRUPTABLE__            
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10910
	    hp = gethostbyname(__hostName);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10911
	    __END_INTERRUPTABLE__            
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10912
	} while ((hp == NULL) 
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10913
		  && (
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10914
			(h_errno == TRY_AGAIN)                      
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10915
		      || errno == EINTR
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10916
#   ifdef IRIX5_3
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10917
		      || (errno == ECONNREFUSED)
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10918
#   endif
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10919
		     )
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10920
	);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10921
	if (hp == 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10922
	    switch (h_errno) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10923
	    case HOST_NOT_FOUND:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10924
		errorString = @symbol(unknownHost);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10925
		break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10926
	    case NO_ADDRESS:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10927
		errorString = @symbol(noAddress);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10928
		break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10929
	    case NO_RECOVERY:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10930
		errorString = @symbol(permanentFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10931
		break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10932
	    case TRY_AGAIN:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10933
		errorString = @symbol(tryAgain);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10934
		break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10935
	    default:
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10936
		errorString = @symbol(unknownError);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10937
		break;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10938
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10939
	    error = __mkSmallInteger(h_errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10940
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10941
	} 
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10942
#  else /* !USE_H_ERRNO */
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10943
	hp = gethostbyname(__hostName);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10944
	if (hp == 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10945
	    errorString = @symbol(unknownHost);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10946
	    error = __mkSmallInteger(-1);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10947
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10948
	}
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10949
#  endif /* !USE_H_ERRNO*/
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10950
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10951
	if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10952
	    errorString = @symbol(unknownHost);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10953
	    error = __mkSmallInteger(-2);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10954
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10955
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10956
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10957
	for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++) 
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10958
	    cnt++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10959
	addrpp = hp->h_addr_list;    
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10960
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10961
	cnt = 1;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10962
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10963
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10964
    result = __ARRAY_NEW_INT(cnt);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10965
    if (result == nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10966
	error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10967
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10968
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10969
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 10970
    for (i = 0; i < cnt; i++) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10971
	OBJ o, resp;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10972
	struct sockaddr_in *sa;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10973
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10974
	resp = __ARRAY_NEW_INT(6);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10975
	if (resp == nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10976
	    error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10977
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10978
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10979
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10980
	__ArrayInstPtr(result)->a_element[i] = resp;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10981
	__STORE(result, resp);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10982
	__ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10983
	__ArrayInstPtr(resp)->a_element[2] = type;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10984
	__ArrayInstPtr(resp)->a_element[3] = proto;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10985
	o = __BYTEARRAY_NEW_INT(sizeof(*sa));        
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10986
	if (o == nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10987
	    error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10988
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10989
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10990
	__ArrayInstPtr(resp)->a_element[4] = o;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10991
	__STORE(resp, o);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10992
	sa = (struct sockaddr_in *)__byteArrayVal(o);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10993
	sa->sin_port = port;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10994
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10995
	if (__hostName) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10996
	    sa->sin_family = hp->h_addrtype;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10997
	    memcpy(&sa->sin_addr, *addrpp, hp->h_length);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10998
	    __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10999
	    if (hp->h_name) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11000
		o = __MKSTRING(hp->h_name);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11001
		if (o == nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11002
		    error = @symbol(allocationFailure);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11003
		    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11004
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11005
		__ArrayInstPtr(resp)->a_element[5] = o;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11006
		__STORE(resp, o);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11007
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11008
	    addrpp++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11009
	} else{
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11010
	    __ArrayInstPtr(resp)->a_element[1] = domain;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11011
	}
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11012
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11013
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11014
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11015
# endif /* ! AI_NUMERICHOST */
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
#else /* ! HAS_SOCKET */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11018
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11019
#endif
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
    error notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11022
	NameLookupError raiseWith:error errorString:errorString.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11023
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11024
    1 to:result size do:[:i | 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11025
	|entry dom info|
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11026
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11027
	info := SocketAddressInfo new.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11028
	entry := result at:i.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11029
	info flags:(entry at:1).
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11030
	info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11031
	info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11032
	info protocol:(self protocolSymbolOf:(entry at:4)).
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11033
	info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11034
	info canonicalName:(entry at:6).
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11035
	result at:i put:info
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11036
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11037
    ^ result
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11038
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11039
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11040
     self getAddressInfo:'localhost' serviceName:nil 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11041
	    domain:nil type:nil protocol:nil flags:nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11042
     self getAddressInfo:'localhost' serviceName:nil 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11043
	    domain:#inet type:#stream protocol:nil flags:nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11044
     self getAddressInfo:'localhost' serviceName:nil 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11045
	    domain:#inet type:#stream protocol:#tcp flags:nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11046
     self getAddressInfo:'blurb.exept.de' serviceName:nil 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11047
	    domain:#inet type:nil protocol:nil flags:nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11048
     self getAddressInfo:'1.2.3.4' serviceName:'bla' 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11049
	    domain:#inet type:nil protocol:nil flags:nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11050
     self getAddressInfo:'localhost' serviceName:'echo' 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11051
	    domain:#inet type:nil protocol:nil flags:nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11052
     self getAddressInfo:nil serviceName:'echo' 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11053
	    domain:#inet type:nil protocol:nil flags:nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11054
     self getAddressInfo:nil serviceName:nil 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11055
	    domain:#inet type:nil protocol:nil flags:nil
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11056
     self getAddressInfo:'www.google.de' serviceName:nil 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11057
	    domain:nil type:nil protocol:nil flags:nil
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11058
     self getAddressInfo:'smc1' serviceName:nil 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11059
	    domain:nil type:nil protocol:nil flags:nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11060
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11061
!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11062
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11063
getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags 
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11064
    "answer an Array containing the hostName and serviceName
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11065
     in socketAddress.
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11066
     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
 11067
     this returns multiple hostnames (if appropriate)"
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11068
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11069
    |error errorString hostName serviceName|
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11070
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11071
%{  /* STACK:32000 */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11072
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11073
#undef xxNI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11074
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11075
#if !defined(NO_SOCKET)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11076
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11077
# ifndef NI_MAXHOST
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11078
#  define NI_MAXHOST 256
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11079
#  define NI_MAXSERV 64
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11080
# endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11081
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11082
    char host[NI_MAXHOST];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11083
    char service[NI_MAXSERV];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11084
    char *hp = 0, *sp = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11085
    int hsz = 0, ssz = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11086
    int ret, __flags;
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11087
    char *bp;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11088
    int nInstBytes, sockAddrSize;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11089
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11090
    if (wantHostName == true) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11091
	hp = host;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11092
	hsz = sizeof(host);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11093
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11094
    if (wantServiceName == true) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11095
	sp = service;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11096
	ssz = sizeof(service);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11097
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11098
    if (hp == 0 && sp == 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11099
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11100
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11101
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11102
    if (!__isBytes(socketAddress)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11103
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11104
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11105
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11106
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11107
    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11108
    sockAddrSize = __byteArraySize(socketAddress);
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11109
    sockAddrSize -= nInstBytes;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11110
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11111
    if (!__isSmallInteger(flags)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11112
	error = @symbol(badArgument5);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11113
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11114
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11115
    __flags = __intVal(flags);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11116
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11117
#if defined(NI_NUMERICHOST)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11118
    if (useDatagram == true) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11119
	__flags |= NI_DGRAM;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11120
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11121
    
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11122
    {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11123
	bp = (char *)(__byteArrayVal(socketAddress));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11124
	bp += nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11125
	__BEGIN_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11126
	ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,   
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11127
			  hp, hsz, sp, ssz, __flags);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11128
	__END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11129
    } while (ret == EAI_SYSTEM && errno == EINTR);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11130
    if (ret != 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11131
	switch (ret) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11132
	case EAI_FAMILY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11133
	    error = @symbol(badProtocol);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11134
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11135
	case EAI_SOCKTYPE:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11136
	    error = @symbol(badSocketType);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11137
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11138
	case EAI_BADFLAGS:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11139
	    error = @symbol(badFlags);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11140
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11141
	case EAI_NONAME:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11142
	    error = @symbol(unknownHost);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11143
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11144
	case EAI_SERVICE:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11145
	    error = @symbol(unknownService);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11146
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11147
	case EAI_ADDRFAMILY :
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11148
	    error = @symbol(unknownHostForProtocol);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11149
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11150
	case EAI_NODATA:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11151
	    error = @symbol(noAddress);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11152
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11153
	case EAI_MEMORY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11154
	    error = @symbol(allocationFailure);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11155
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11156
	case EAI_FAIL:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11157
	    error = @symbol(permanentFailure);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11158
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11159
	case EAI_AGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11160
	    error = @symbol(tryAgain);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11161
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11162
	case EAI_SYSTEM:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11163
	    error = @symbol(systemError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11164
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11165
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11166
	    error = @symbol(unknownError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11167
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11168
	errorString = __MKSTRING(gai_strerror(ret));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11169
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11170
    } 
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11171
# else /* ! NI_NUMERICHOST */
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11172
    {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11173
	/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11174
	 * Do it using gethostbyaddr()
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11175
	 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11176
	struct sockaddr_in *sa;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11177
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11178
	if (sockAddrSize < sizeof(*sa)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11179
	    error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11180
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11181
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11182
	bp = (char *)(__byteArrayVal(socketAddress));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11183
	bp += nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11184
	sa = (struct sockaddr_in *)bp;
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11185
    
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11186
	if (sp) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11187
	    struct servent *servp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11188
	    char *__proto = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11189
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11190
	    __proto = (useDatagram == true ? "udp" : "tcp");
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11191
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11192
	    servp = getservbyport(sa->sin_port, __proto);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11193
	    if (servp) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11194
		sp = servp->s_name;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11195
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11196
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11197
	if (hp) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11198
	    struct hostent *hostp;
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11199
#  ifdef USE_H_ERRNO
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11200
	    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11201
		/* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11202
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11203
		hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11204
		/* __END_INTERRUPTABLE__ */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11205
	    } while ((hostp == NULL) 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11206
		      && ((h_errno == TRY_AGAIN)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11207
			  || errno == EINTR
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11208
#   ifdef IRIX5_3
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11209
			  || (errno == ECONNREFUSED)
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11210
#   endif
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11211
			 )
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11212
	    );
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11213
	    if (hostp == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11214
		switch (h_errno) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11215
		case HOST_NOT_FOUND:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11216
		    errorString = @symbol(unknownHost);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11217
		    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11218
		case NO_ADDRESS:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11219
		    errorString = @symbol(noAddress);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11220
		    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11221
		case NO_RECOVERY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11222
		    errorString = @symbol(permanentFailure);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11223
		    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11224
		case TRY_AGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11225
		    errorString = @symbol(tryAgain);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11226
		    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11227
		default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11228
		    errorString = @symbol(unknownError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11229
		    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11230
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11231
		error = __mkSmallInteger(h_errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11232
		goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11233
	    } 
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11234
#  else /* !USE_H_ERRNO */
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11235
	    hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11236
	    if (hostp == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11237
		errorString = @symbol(unknownHost);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11238
		error = __mkSmallInteger(-1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11239
		goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11240
	    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11241
#  endif /* !USE_H_ERRNO*/
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11242
	    hp = hostp->h_name;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11243
	}
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
# endif /* ! NI_NUMERICHOST */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11246
7461
00fb6fbd9b4f Refetch pointers to objects after __BEGIN__INTERRUPTABLE_
Stefan Vogel <sv@exept.de>
parents: 7460
diff changeset
 11247
    if (hp) 
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11248
	hostName = __MKSTRING(hp);
7461
00fb6fbd9b4f Refetch pointers to objects after __BEGIN__INTERRUPTABLE_
Stefan Vogel <sv@exept.de>
parents: 7460
diff changeset
 11249
    if (sp) 
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11250
	serviceName = __MKSTRING(sp);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11251
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11252
#else
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11253
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11254
#endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11255
%}.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11256
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11257
	NameLookupError raiseWith:error errorString:errorString.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11258
	^ nil
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11259
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11260
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11261
    ^ Array with:hostName with:serviceName
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11262
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11263
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11264
     self getNameInfo:
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11265
	(self getAddressInfo:'localhost' serviceName:'echo' 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11266
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11267
	 wantHostName:true wantServiceName:true datagram:false flags:0 
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11268
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11269
     self getNameInfo:
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11270
	(self getAddressInfo:'exept.exept.de' serviceName:'echo' 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11271
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11272
	 wantHostName:true wantServiceName:true datagram:false flags:0       
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11273
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11274
! !
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11275
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11276
!UnixOperatingSystem::SocketHandle methodsFor:'accepting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11277
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11278
acceptWithPeerAddressBuffer:peerOrNil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11279
    "accept a connection on a server port.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11280
     Returns a new SocketHandle or nil if the operation
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11281
     would block.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11282
     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
 11283
     of the connection peer is stored into it."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11284
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11285
    |error newFd|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11286
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11287
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11288
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11289
    int sock, newSock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11290
    struct sockaddr *sap;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11291
    int alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11292
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11293
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11294
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11295
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11296
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11297
    if (peerOrNil != nil && 
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11298
	(!__isNonNilObject(peerOrNil) ||
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11299
	 (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11300
	error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11301
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11302
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11303
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11304
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11305
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11306
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11307
    if (peerOrNil == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11308
	alen = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11309
	sap = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11310
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11311
	alen =  __byteArraySize(peerOrNil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11312
	sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11313
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11314
    newSock = accept(sock, sap, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11315
    if (newSock < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11316
	switch (errno) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11317
	case EINTR:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11318
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11319
	    goto again;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11320
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11321
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11322
	case EWOULDBLOCK:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11323
# if defined(EAGAIN) && (EAGAIN != EWOULDBLOCK)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11324
	case EAGAIN:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11325
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11326
#else
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11327
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11328
	case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11329
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11330
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11331
	    RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11332
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11333
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11334
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11335
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11336
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11337
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11338
    newFd = __mkSmallInteger(newSock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11339
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11340
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11341
#endif /* not NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11342
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11343
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11344
	^ self error:error.
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11345
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11346
    ^ self class for:newFd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11347
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11348
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11349
!UnixOperatingSystem::SocketHandle methodsFor:'binding'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11351
bindTo:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11352
    "low level bind - 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11353
     Set the local address of the socket"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11354
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11355
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11356
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11357
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11358
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11359
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11360
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11361
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11362
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11363
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11364
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11365
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11366
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11367
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11368
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11369
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11370
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11371
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11372
    sockaddr_size = __byteArraySize(socketAddress);
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
 11373
    sock = __smallIntegerVal(__INST(fd));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11374
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11375
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11376
    ret = bind(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11377
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11378
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11379
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11380
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11381
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11382
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11383
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11384
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11385
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11386
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11387
    err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11388
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11389
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11390
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11391
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11392
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11393
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11394
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11395
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11396
     (Socket domain:#inet type:#stream)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11397
	 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11398
	 reuseAddress:false ;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11399
     yourself
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11400
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11401
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11402
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11403
!UnixOperatingSystem::SocketHandle methodsFor:'connecting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11404
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11405
cancelConnect
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11406
    "cancel an asynchronous connect in progress"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11407
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11408
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11409
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11410
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11411
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11412
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11413
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11414
    struct sockaddr sockaddr = { AF_UNSPEC };
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11415
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11416
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11417
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11418
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11419
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11420
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11421
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11422
    /* 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11423
     * (dis-) connect by connecting to AF_UNSPEC socket 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11424
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11425
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11426
    ret = connect(sock, &sockaddr, sizeof(sockaddr));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11427
    if (ret < 0) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11428
       switch(errno) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11429
	   case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11430
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11431
	    case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11432
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11433
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11434
		goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11435
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11436
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11437
		error = __MKSMALLINT(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11438
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11439
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11440
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11441
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11442
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11443
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11444
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11445
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11446
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11447
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11448
    ].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11449
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11450
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11451
connectTo:socketAddress 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11452
    "low level connect; connect to a socket address.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11453
     Return true if connection has been established,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11454
     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
 11455
     completed. If an error occured, an OSError is raised"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11456
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11457
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11458
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11459
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11460
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11461
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11462
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11463
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11464
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11465
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11466
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11467
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11468
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11469
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11470
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11471
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11472
	goto err;
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
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11475
    sockaddr_size = __qSize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11476
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11477
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11478
    ret = connect(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11479
    if (ret >= 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11480
	RETURN(true)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11481
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11482
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11483
    switch(errno) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11484
	case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11485
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11486
	case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11487
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11488
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11489
	    goto again;
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11490
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11491
# if defined(EINPROGRESS) || defined(EALREADY)
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11492
#  ifdef EINPROGRESS
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11493
	case EINPROGRESS: 
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11494
#  endif
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11495
#  ifdef EALREADY
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11496
	case EALREADY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11497
#  endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11498
	    RETURN(false);
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 11499
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11500
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11501
    default:
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11502
	error = __MKSMALLINT(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11503
	break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11504
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11505
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11506
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11507
#endif /* NO_SOCKET */
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
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11510
	 ^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11511
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11512
    ^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11513
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
     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
 11516
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11517
     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
 11518
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11519
     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
 11520
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11521
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11522
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11523
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11524
!UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11525
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11526
receiveFrom:socketAddress buffer:aDataBuffer start:startIndex for:nBytes flags:flags 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11527
    "receive datagramm data - put address of originating host into
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11528
     anAddressBuffer, data into aBuffer. For ST-80 compatibility,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11529
     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
 11530
     the addressBytes-message (i.e. be a SocketAddress instance).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11531
     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
 11532
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11533
     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
 11534
     receiving, using #readWait or #readWaitWithTimeout:."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11535
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11536
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11537
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11538
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11539
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11540
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11541
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11542
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11543
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11544
    int alen0, alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11545
    int n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11546
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11547
    int __flags, __startIndex, __nBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11548
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11549
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11550
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11551
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11552
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11553
    if (!__isSmallInteger(startIndex) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11554
	(__startIndex = __intVal(startIndex)-1) < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11555
	if (startIndex == nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11556
	    __startIndex = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11557
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11558
	    error = @symbol(badArgument3);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11559
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11560
	}
6350
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
    if (__isSmallInteger(nBytes)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11563
	__nBytes = __intVal(nBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11564
    } else if (nBytes == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11565
	__nBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11566
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11567
	error = @symbol(badArgument4);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11568
	goto err;
6350
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
    if (!__isInteger(flags)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11571
	error = @symbol(badArgument5);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11572
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11573
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11574
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11575
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11576
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11577
    oClass = __Class(aDataBuffer);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11578
    switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11579
	case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11580
	case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11581
	case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11582
	case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11583
	case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11584
	case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11585
	case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11586
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11587
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11588
	    error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11589
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11590
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11591
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11592
    nInstVars = __intVal(_ClassInstPtr(oClass)->c_ninstvars);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11593
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11594
    objSize = __qSize(aDataBuffer) - nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11595
    nInstBytes += __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11596
    objSize -= __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11597
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11598
    if (__nBytes >= 0 &&__nBytes < objSize) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11599
	objSize = __nBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11600
    }
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
    if (socketAddress == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11603
	alen0 = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11604
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11605
	if (!__isNonNilObject(socketAddress) ||
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11606
	    (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11607
	    error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11608
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11609
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11610
	alen0 = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11611
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11612
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11613
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11614
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11615
    alen = alen0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11616
    if (alen)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11617
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11618
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11619
    n = recvfrom(sock, cp, objSize, __flags, saPtr, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11620
    if (n < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11621
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11622
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11623
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11624
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11625
	    error = __MKSMALLINT(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11626
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11627
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11628
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11629
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11630
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11631
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11632
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11633
    ^ self error:error.
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11636
sendTo:socketAddress buffer:aDataBuffer start:startIndex for:maxBytes flags:flags 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11637
    "send datagramm data - fetch address of destination host from
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11638
     anAddressBuffer, data from aDataBuffer starting at startIndex,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11639
     sending count bytes.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11640
     SocketAddress must be an instance of SocketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11641
     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
 11642
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11643
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11644
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11645
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11646
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11647
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11648
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11649
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11650
    int alen, n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11651
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11652
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11653
    int __flags;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11654
    int offs, __startIndex, __maxBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11655
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11656
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11657
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11658
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11659
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11660
    if (!__isSmallInteger(startIndex) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11661
	(__startIndex = __intVal(startIndex)-1) < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11662
	if (startIndex == nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11663
	    __startIndex = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11664
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11665
	    error = @symbol(badArgument3);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11666
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11667
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11668
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11669
    if (__isSmallInteger(maxBytes)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11670
	__maxBytes = __intVal(maxBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11671
    } else if (maxBytes == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11672
	__maxBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11673
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11674
	error = @symbol(badArgument4);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11675
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11676
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11677
    if (!__isInteger(flags)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11678
	error = @symbol(badArgument5);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11679
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11680
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11681
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11682
    sock = __smallIntegerVal(__INST(fd));
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
    oClass = __Class(aDataBuffer);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11685
    switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11686
	case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11687
	    offs = __startIndex;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11688
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11689
	case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11690
	case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11691
	    offs = __startIndex * 2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11692
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11693
	case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11694
	case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11695
	    offs = __startIndex * 4;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11696
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11697
	case LONGLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11698
	case SLONGLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11699
	    offs = __startIndex * 8;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11700
# ifdef __NEED_LONGLONG_ALIGN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11701
	    offs += 4;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11702
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11703
	case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11704
	    offs = __startIndex * sizeof(float);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11705
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11706
	case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11707
	    offs = __startIndex * sizeof(double);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11708
# ifdef __NEED_DOUBLE_ALIGN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11709
	    offs += 4;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11710
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11711
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11712
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11713
	    error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11714
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11715
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11716
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11717
    nInstVars = __smallIntegerVal(_ClassInstPtr(oClass)->c_ninstvars);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11718
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11719
    objSize = __qSize(aDataBuffer) - nInstBytes - offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11720
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11721
    if (__maxBytes >= 0 && __maxBytes < objSize) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11722
# ifdef DGRAM_DEBUG
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11723
	printf("cut off ...\n");
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11724
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11725
	objSize = __maxBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11726
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11727
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11728
    if (socketAddress == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11729
	alen = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11730
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11731
	if (! __isByteArray(socketAddress)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11732
	    error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11733
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11734
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11735
	alen = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11736
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11737
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11738
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11739
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11740
    if (alen)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11741
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11742
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes + offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11743
    n = sendto(sock, cp, objSize, __flags, saPtr, alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11744
    if (n < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11745
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11746
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11747
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11748
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11749
	    error = __MKSMALLINT(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11750
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11751
	}
6350
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
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11754
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11755
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11756
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11757
    ^ self error:error.
6350
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
6434
f23d12900e18 category rename
Claus Gittinger <cg@exept.de>
parents: 6421
diff changeset
 11760
!UnixOperatingSystem::SocketHandle methodsFor:'initialization'!
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
domain:domainArg type:typeArg protocol:protocolArg 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11763
    "set up socket with domain, type and protocol number.
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11764
     This is a low level entry; no binding, listening or connect is done. 
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11765
     All arguments must be symbols from one of
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11766
     domainArg: #AF_INET, #AF_UNIX, #AF_APPLETALK (#inet, #unix, #appletalk, #x25) .. 
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11767
     type: #SOCK_STREAM, #SOCK_DGRAM (#stream, #datagram, #raw) .. 
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11768
     protocol: #tcp, #udp, #raw .. 
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11769
    "
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11770
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11771
    |error domainCode typeCode protocolNumber|
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11772
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11773
    domainCode := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11774
    typeCode := OperatingSystem socketTypeCodeOf:typeArg.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11775
    protocolArg notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11776
	protocolNumber := self class protocolCodeOf:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11777
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11778
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11779
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11780
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11781
    int dom, typ, proto = 0, sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11782
    int on = 1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11783
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11784
    if (__INST(fd) != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11785
	error = @symbol(internalError);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11786
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11787
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11788
    if (! __isSmallInteger(domainCode)) { 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11789
	error = @symbol(badArgument1);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11790
	goto err;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11791
    }
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11792
    if (! __isSmallInteger(typeArg)) { 
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11793
	error = @symbol(badArgument2);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11794
	goto err;
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
    if (protocolNumber != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11797
	if (!__isSmallInteger(protocolNumber)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11798
	    error = @symbol(badArgument3);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11799
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11800
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11801
	proto = __smallIntegerVal(protocolNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11802
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11803
    dom = __smallIntegerVal(domainCode);    
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11804
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
     * get socket-type and protocol-type
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11807
     */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11808
    typ = __intVal(typeArg);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11809
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11810
againSocket:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11811
    sock = socket(dom, typ, proto);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11812
    if (sock < 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11813
	if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11814
	    __HANDLE_INTERRUPTS__;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11815
	    goto againSocket;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11816
	} else 
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11817
# if defined(EPROTONOSUPPORT) /* for SGI */
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11818
	if (errno == EPROTONOSUPPORT && proto != 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11819
	    proto = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11820
	    goto againSocket;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11821
	} else
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11822
# endif
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11823
	{
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11824
	    error = __mkSmallInteger(errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11825
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11826
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11827
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11828
    __INST(fd) = __mkSmallInteger(sock);
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
err:;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11831
# else /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11832
    error := @symbol(notImplemented);
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11833
# endif /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11834
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11835
    error notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 11836
	^ self error:error.
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
    self register.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11839
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11840
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11841
     self new domain:#inet type:#stream protocol:nil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11842
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11843
! !
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
!UnixOperatingSystem::SocketHandle methodsFor:'misc'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11846
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11847
getOptionsLevel:level name:name 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11848
    "answer a ByteArray containing the socket option value 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11849
     named name at level"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11850
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11851
    |error bytes size|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11852
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11853
    bytes := ByteArray new:256.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11854
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11855
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11856
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11857
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11858
    int intval, sz;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11859
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11860
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11861
    if (!__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11862
	error = @symbol(badFd);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11863
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11864
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11865
    if (!__bothSmallInteger(level, name)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11866
	error = @symbol(badArgument);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11867
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11868
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11869
    if (!__isByteArray(bytes)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11870
	error = @symbol(internalError);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11871
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11872
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11873
    p = __byteArrayVal(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11874
    sz = __byteArraySize(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11875
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11876
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11877
    if (getsockopt(sock, __smallIntegerVal(level), __smallIntegerVal(name), p, &sz) < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11878
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11879
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11880
    size = __mkSmallInteger(sz);
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
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11883
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11884
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11885
    error notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11886
	^ self error:error
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
    ^ bytes copyTo:size
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11889
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11890
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11891
listenFor:aNumber 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11892
    "start listening.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11893
     aNumber is the number of connect indications queues
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11894
     by the operating system"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11895
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11896
    |error|
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
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11899
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11900
    int sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11901
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11902
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11903
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11904
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11905
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11906
    if (!__isSmallInteger(aNumber)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11907
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11908
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11909
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11910
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11911
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11912
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11913
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11914
    ret = listen(sock, __smallIntegerVal(aNumber));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11915
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11916
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11917
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11918
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11919
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11920
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11921
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11922
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11923
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11924
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11925
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11926
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11927
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11928
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11929
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11930
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11931
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11932
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11933
setOptionsLevel:level name:name value:value 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11934
    "set the socket option name at level to value.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11935
     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
 11936
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11937
    |error|
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
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11941
    int sock;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11942
    int __level, __name, intval, sz;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11943
    char *p;
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 (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11946
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11947
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11948
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11949
    if (__isSmallInteger(level)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11950
	__level = __smallIntegerVal(level);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11951
    } else if (level == @symbol(SOL_SOCKET)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11952
	__level = SOL_SOCKET;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11953
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11954
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11955
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11956
    }    
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11957
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11958
    if (__isSmallInteger(name)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11959
	__name = __smallIntegerVal(name);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11960
    } else if (name == @symbol(SO_REUSEADDR)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11961
	__name = SO_REUSEADDR;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11962
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11963
	error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11964
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11965
    }    
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11966
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11967
    if (__isSmallInteger(value)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11968
	intval = __intVal(value);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11969
	p = (char *) &intval;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11970
	sz = sizeof(intval);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11971
    } else if (__isByteArray(value)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11972
	p = __byteArrayVal(value);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11973
	sz = __byteArraySize(value);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11974
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11975
	error = @symbol(badArgument3);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11976
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11977
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11978
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11979
    sock = __smallIntegerVal(__INST(fd));
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11980
    if (setsockopt(sock, __level, __name, p, sz) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11981
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11982
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11983
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11984
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11985
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11986
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11987
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11988
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 11989
    ^ nil.
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11992
shutdown:anInteger 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11993
    "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
 11994
     anInteger == 0   no reads will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11995
     anInteger == 1   no writes will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11996
     anInteger == 2   neither reads nor writes will be performed.
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11997
		      Pending data is discarded. This is faster tha 
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11998
		      close, which may wait until pending (written)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11999
		      data has been read by the other side"
6350
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
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12002
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
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12005
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12006
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12007
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12008
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12009
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12010
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12011
    if (!__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12012
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12013
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12014
    }
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
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12017
    ret = shutdown(__smallIntegerVal(__INST(fd)), __smallIntegerVal(anInteger));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12018
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12019
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12020
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12021
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12022
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12023
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12024
	}
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12027
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12028
#endif /*NO_SOCKET*/
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
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12031
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12032
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12033
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12034
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12035
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12036
!UnixOperatingSystem::SocketHandle methodsFor:'queries'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12037
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12038
getNameInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12039
    "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
 12040
     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
 12041
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12042
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12043
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12044
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12045
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12046
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12047
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12048
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12049
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12050
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12051
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12052
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12053
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12054
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12055
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12056
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12057
	goto err;
6350
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
    sockaddr_size = __byteArraySize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12060
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12061
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12062
    ret = getsockname(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12063
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12064
	error = __MKSMALLINT(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12065
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12066
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12067
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12068
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12069
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12070
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12071
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12072
    ^ nil.
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12075
getPeerInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12076
    "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
 12077
     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
 12078
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12079
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12080
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12081
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12082
#ifndef NO_SOCKET
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12083
    int __sock;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12084
    int __sockaddr_size;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12085
    int __ret;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12086
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12087
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12088
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12089
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12090
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12091
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12092
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12093
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12094
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12095
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12096
    __sockaddr_size = __byteArraySize(socketAddress);
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12097
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12098
    __sock = __smallIntegerVal(__INST(fd));
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12099
    __ret = getpeername(__sock, (struct sockaddr *)__byteArrayVal(socketAddress), 
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12100
				&__sockaddr_size);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12101
    if (__ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12102
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12103
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12104
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12105
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12106
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12107
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12108
	^ self error:error
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
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12111
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12112
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12113
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12115
version
7681
7c63f0b47f0d oops: millisecondDelay: was duplicated
Claus Gittinger <cg@exept.de>
parents: 7656
diff changeset
 12116
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.183 2003-10-22 22:02:18 cg Exp $'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12117
! !
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 12118
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12119
UnixOperatingSystem initialize!
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 12120
UnixOperatingSystem::FileDescriptorHandle initialize!