UnixOperatingSystem.st
author Stefan Vogel <sv@exept.de>
Wed, 10 Jul 2002 13:46:34 +0200
changeset 6617 e582d421c0b7
parent 6579 2553ff4b56d9
child 6760 e62624827ffe
permissions -rw-r--r--
Share and close /dev/null filediscriptors.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
     3
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    13
"{ Package: 'stx:libbasic' }"
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    14
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
AbstractOperatingSystem subclass:#UnixOperatingSystem
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    16
	instanceVariableNames:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    17
	classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory'
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    18
	poolDictionaries:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    19
	category:'OS-Unix'
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    20
!
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    21
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    22
Object subclass:#FileDescriptorHandle
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    23
	instanceVariableNames:'fd'
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    24
	classVariableNames:'OpenFiles'
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    25
	poolDictionaries:''
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    26
	privateIn:UnixOperatingSystem
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    27
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    28
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    29
OSFileHandle subclass:#FilePointerHandle
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    30
	instanceVariableNames:''
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    31
	classVariableNames:''
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    32
	poolDictionaries:''
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    33
	privateIn:UnixOperatingSystem
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    34
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    35
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    36
Object subclass:#FileStatusInfo
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
    37
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
    38
		numLinks'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    39
	classVariableNames:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    40
	poolDictionaries:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
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
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    44
Object subclass:#OSProcessStatus
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    45
	instanceVariableNames:'pid status code core'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    46
	classVariableNames:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    47
	poolDictionaries:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    48
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    51
UnixOperatingSystem::FileDescriptorHandle subclass:#SocketHandle
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    52
	instanceVariableNames:''
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    53
	classVariableNames:'ProtocolCache'
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    54
	poolDictionaries:''
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    55
	privateIn:UnixOperatingSystem
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    56
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    57
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!UnixOperatingSystem primitiveDefinitions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
#if defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
# ifndef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
#  define WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
#ifdef LINUX
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    70
# define __xxUSE_GNU      /* new */
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    71
# undef HAS_UTS_DOMAINNAME
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
    72
# define NET_IF_SUPPORT
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    73
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    74
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    75
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    76
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    77
# endif
3956
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    78
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    79
# ifndef _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    80
#  include <sys/types.h>
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    81
#  define _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    82
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
  /* use inline string macros */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
# define __STRINGDEFS__
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
    85
# include "linuxIntern.h"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
# define WANT_SHM
3544
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
    91
# define HAS_SETENV
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
    92
# define HAS_UNSETENV
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
    93
# include <time.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
#ifdef ultrix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
#ifdef hpux
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
#ifdef solaris
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
#if defined(SYSV4) && defined(i386) /* e.g. unixware */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
 * notice: although many systems' include files
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
 * already block against multiple inclusion, some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
 * do not. Therefore, this is done here again.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
 * (it does not hurt)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
 */ 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
#ifdef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
# ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
#  include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
#  define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
# include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
# define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
# include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
# define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
#endif /* WANT_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
extern int shmctl(), shmget(), shmdt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
extern char * shmat();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
# include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
# define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
# include <sys/ipc.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
# define _SYS_IPC_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
# include <sys/shm.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
# define _SYS_SHM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
#endif /* WANT_SHM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
# include <sys/syssgi.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
#ifdef transputer
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
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
#else /* not transputer */
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
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
# ifdef SYSV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
#  ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
#   include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
#   define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
#  ifndef _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
#   ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
#    include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
#    define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
#   endif
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_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
#   include <sys/times.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
#   define _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
#  ifndef _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
#   include <sys/file.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
#   define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
#  if ! defined(sco3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
#   ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
#    include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
#    define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
#  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(isc3_2) || defined(sco3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
#   ifndef _SYS_TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
#    include <sys/time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
#    define _SYS_TIME_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)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
#   if defined(PCS) && defined(mips)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
#    include "/usr/include/bsd/sys/time.h"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
#    include "/usr/include/sys/time.h"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
#    ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
#     include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
#     define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
#    endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
#  if defined(isc3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
#   include <sys/bsdtypes.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
# else /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   225
#  ifndef _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   226
#   include <sys/time.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   227
#   define _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   228
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   229
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   230
#  ifndef _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   231
#   include <sys/types.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   232
#   define _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   233
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   234
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
# endif /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
# ifdef aix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
#  ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
#   include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
#   define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
#  ifndef _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
#   include <sys/select.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
#   define _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
# endif /* aix */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   251
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   252
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   253
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   254
# endif
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   255
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   256
# ifndef _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   257
#  include <pwd.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   258
#  define _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   259
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   260
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   261
# ifndef NO_GRP_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   262
#  ifndef _GRP_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   263
#   include <grp.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   264
#   define _GRP_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
#  endif
4105
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
# ifndef _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
#  include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
#  define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
# ifndef _SYS_FILE_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   275
#  include <sys/file.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
#  define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
# ifndef _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
#  include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
#  define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
# ifndef _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
#  include <fcntl.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
#  define _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   289
# ifndef _SYS_IOCTL_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   290
#  include <sys/ioctl.h>
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   291
#  define _SYS_IOCTL_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
# if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
#  define HAS_LOCALECONV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
# if defined (HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
#  ifndef _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
#   include <locale.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
#   define _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
#  endif
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
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   305
# if defined (HAS_FTIME)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   306
#  include <sys/timeb.h>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   307
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   308
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
/* 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
 * posix systems should define these ... 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
 * but on some (older) systems, they are not.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
#  ifdef S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
#   define S_IXUSR S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
#   define S_IXGRP (S_IEXEC>>3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
#   define S_IXOTH (S_IEXEC>>6)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
#  define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
#  define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
#  define S_IXOTH 0001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
# ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
#  define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
#  define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
#  define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
# ifndef S_IWUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
#  define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
#  define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
#  define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
# ifndef MAXPATHLEN
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   340
#  ifndef NO_SYS_PARAM_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   341
#   include <sys/param.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
#  ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
#   ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
#    define MAXPATHLEN FILENAME_MAX
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
#    ifdef MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
#     define MAXPATHLEN MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
#    else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
#     define MAXPATHLEN 1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
#    endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
# if defined(HAS_UNAME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
#  include <sys/utsname.h>
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
# if defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
#  include <stropts.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
4285
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   364
# ifndef aix
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   365
#  include <sys/termios.h>
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   366
# endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   367
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
 * NeXT has no pid_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
 * and no sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
# ifdef NEXT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
   typedef int pid_t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
#  define sigemptyset(set)      ((*(set) = 0L), 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
#  define HAS_GETDOMAINNAME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
#  define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
# endif
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 sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
#  undef NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
#  undef HAS_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
#  define HAS_WAIT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
#  define HAS_SIGACTION
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
 * some (BSD ?) have no timezone global,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
 * but provide the info in struct timezone.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
# if defined(ultrix) || defined(sunos) || defined(NEXT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
#  define HAS_NO_TIMEZONE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
 * 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
   396
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
# ifndef SA_RESTART
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
#  define SA_RESTART    0
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
# ifndef SA_SIGINFO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
#  define SA_SIGINFO    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
#  include <sys/wait.h>
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
# if defined(HAS_SYSINFO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
#  include <sys/systeminfo.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   412
# ifdef LINUX
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   413
#  include <linux/kernel.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   414
#  include <linux/sys.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   415
# endif
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   416
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   417
# if defined(HAS_GETSYSINFO)
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   418
#  include <sys/sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   419
#  include <machine/hal_sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   420
#  include <machine/hal/cpuconf.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   421
# endif
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   422
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   423
# if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   424
#  ifndef _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   425
#   include <unistd.h>
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   426
#   define _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   427
#  endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   428
# endif
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   429
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
#endif /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
 * 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
   434
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
#ifndef errno
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
 extern errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
#endif
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
 * some (old ?) systems do not define this ...
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
#if !defined(R_OK) && !defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
# define R_OK    4       /* Test for Read permission */ 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
# define W_OK    2       /* Test for Write permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
# define X_OK    1       /* Test for eXecute permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
# 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
   447
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   449
#define SIGHANDLER_ARG
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
#ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
#ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
#endif
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
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
 * 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
   460
 * explicit add of those we know to have ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
#ifdef __osf__
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
# define TIME_T time_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
# define OFF_T  off_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
#ifndef TIME_T
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
# define TIME_T long
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
#ifndef OFF_T
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
# define OFF_T  long
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
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
 * where is the timezone info ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
 */
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   477
#ifdef HAS_TM_GMTOFF
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   478
# define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   479
#else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   480
# if defined(HAS_NO_TIMEZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   481
#  if defined(HAS_NO_TM_GMTOFF)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   482
#   define TIMEZONE(tmPtr)       0
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   483
#  else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   484
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   485
#  endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
# else
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   487
#  if defined(HAS_ALTZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   488
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : altzone)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   489
#  else  /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   490
#   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
   491
#  endif /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   492
# endif
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   493
#endif                                                                                                                                                                                                                                                                                                                                                                                                                               
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
3595
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   495
#ifndef CONST
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   496
# ifdef __GNUC__
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   497
#  define CONST const
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   498
# else
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   499
#  define CONST /* nothing */
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   500
# endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   501
#endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   502
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   503
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   504
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   505
 * Socket defines
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   506
 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   507
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   508
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   509
#if defined(transputer)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   510
# define NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   511
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   512
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   513
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   514
 * which protocols can we support ?
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   515
 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   516
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   517
# define WANT__AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   518
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   519
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   520
#define WANT__AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   521
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   522
#ifdef __VMS__
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   523
# undef WANT__AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   524
# define WANT_AF_DECnet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   525
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   526
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   527
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   528
#ifdef LINUX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   529
/* kludge to avoid some redefines ... */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   530
# define _ARPA_NAMESER_H
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   531
# define _NETINET_TCP_H
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   532
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   533
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   534
#if !defined(NO_SOCKET)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   535
# if defined(IRIS) && !defined(IRIX5)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   536
   /* no socket.h on 4.0.5h ?!?!? */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   537
#  ifndef AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   538
#   define AF_UNIX 1
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   539
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   540
#  ifndef AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   541
#   define AF_INET 2
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
#  ifndef SOCK_STREAM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   545
#   define SOCK_STREAM 1
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   546
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   547
#  ifndef SOCK_DGRAM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   548
#   define SOCK_DGRAM  2
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   549
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   550
#  ifndef SOCK_RAW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   551
#   define SOCK_RAW    3
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   552
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   553
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   554
#  include <sys/socket.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   555
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   556
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   557
# ifdef NEXT3
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   558
#  include <netinet/in_systm.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   559
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   560
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   561
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   562
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   563
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   564
 * see what we want ...
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   565
 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   566
#ifdef WANT__AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   567
# ifdef AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   568
#  ifndef PF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   569
#   define PF_UNIX AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   570
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   571
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   572
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   573
# undef AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   574
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   575
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   576
#ifdef WANT__AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   577
# ifdef AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   578
#  ifndef PF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   579
#   define PF_INET AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   580
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   581
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   582
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   583
# undef AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   584
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   585
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   586
#ifdef WANT__AF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   587
# ifdef AF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   588
#  ifndef PF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   589
#   define PF_INET6 AF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   590
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   591
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   592
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   593
# undef AF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   594
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   595
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   596
#ifdef WANT__AF_DECnet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   597
# ifdef AF_DECnet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   598
#  ifndef PF_DECnet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   599
#   define PF_DECnet AF_DECnet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   600
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   601
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   602
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   603
# undef AF_DECnet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   604
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   605
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   606
#ifdef WANT__AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   607
# ifdef AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   608
#  ifndef PF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   609
#   define PF_APPLETALK AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   610
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   611
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   612
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   613
# undef AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   614
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   615
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   616
#ifdef WANT__AF_X25     /* X.25 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   617
# ifdef AF_X25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   618
#  ifndef PF_X25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   619
#   define PF_X25 AF_X25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   620
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   621
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   622
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   623
# undef AF_X25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   624
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   625
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   626
#ifdef WANT__AF_NS      /* Xerox XNS */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   627
# ifdef AF_NS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   628
#  ifndef PF_NS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   629
#   define PF_NS AF_NS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   630
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   631
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   632
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   633
# undef AF_NS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   634
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   635
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   636
#ifdef WANT__AF_SNA     /* IBM SNA */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   637
# ifdef AF_SNA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   638
#  ifndef PF_SNA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   639
#   define PF_SNA AF_SNA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   640
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   641
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   642
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   643
# undef AF_SNA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   644
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   645
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   646
#ifdef WANT__AF_RAW     /* RAW packets */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   647
# ifdef AF_RAW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   648
#  ifndef PF_RAW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   649
#   define PF_RAW AF_RAW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   650
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   651
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   652
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   653
# undef AF_RAW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   654
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   655
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   656
#ifdef WANT__AF_ISO     /* ? */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   657
# ifdef AF_ISO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   658
#  ifndef PF_ISO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   659
#   define PF_ISO AF_ISO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   660
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   661
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   662
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   663
# undef AF_ISO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   664
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   665
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   666
#ifdef WANT__AF_NETBIOS /* NETBIOS */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   667
# ifdef AF_NETBIOS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   668
#  ifndef PF_NETBIOS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   669
#   define PF_NETBIOS AF_NETBIOS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   670
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   671
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   672
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   673
# undef AF_NETBIOS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   674
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   675
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   676
#ifdef WANT__AF_CCITT /* ? */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   677
# if defined(AF_CCITT) && (AF_CCITT != AF_X25)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   678
#  ifndef PF_CCITT
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   679
#   define PF_CCITT AF_CCITT
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   680
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   681
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   682
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   683
# undef AF_CCITT
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   684
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   685
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   686
#ifdef WANT__AF_IPX /* Novell IPX */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   687
# ifdef AF_IPX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   688
#  ifndef PF_IPX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   689
#   define PF_IPX AF_IPX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   690
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   691
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   692
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   693
# undef AF_IPX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   694
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   695
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   696
#ifdef WANT__AF_AX25 /* Amateur Radio AX.25 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   697
# ifdef AF_AX25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   698
#  ifndef PF_AX25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   699
#   define PF_AX25 AF_AX25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   700
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   701
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   702
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   703
# undef AF_AX25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   704
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   705
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   706
#ifdef WANT__AF_NETROM /* Amateur Radio NET/ROM */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   707
# ifdef AF_NETROM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   708
#  ifndef PF_NETROM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   709
#   define PF_NETROM AF_NETROM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   710
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   711
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   712
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   713
# undef AF_NETROM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   714
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   715
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   716
#ifdef WANT__AF_BRIDGE /* multiprotocol bridge */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   717
# ifdef AF_BRIDGE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   718
#  ifndef PF_BRIDGE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   719
#   define PF_BRIDGE AF_BRIDGE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   720
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   721
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   722
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   723
# undef AF_BRIDGE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   724
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   725
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   726
#ifdef WANT__AF_BSC /* BISYNC 2780/3780 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   727
# ifdef AF_BSC
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   728
#  ifndef PF_BSC
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   729
#   define PF_BSC AF_BSC
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   730
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   731
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   732
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   733
# undef AF_BSC
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   734
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   735
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   736
#ifdef WANT__AF_ROSE /* Amateur Radio X.25 PLP */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   737
# ifdef AF_ROSE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   738
#  ifndef PF_ROSE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   739
#   define PF_ROSE AF_ROSE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   740
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   741
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   742
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   743
# undef AF_ROSE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   744
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   745
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   746
#ifdef WANT__AF_ATM /* ATM Services */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   747
# ifdef AF_ATM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   748
#  ifndef PF_ATM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   749
#   define PF_ATM AF_ATM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   750
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   751
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   752
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   753
# undef AF_ATM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   754
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   755
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   756
#ifdef WANT__AF_BAN /* BAN / VINES IP Services */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   757
# ifdef AF_BAN
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   758
#  ifndef PF_BAN
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   759
#   define PF_BAN AF_BAN
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   760
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   761
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   762
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   763
# undef AF_BAN
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   764
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   765
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   766
#ifdef WANT__AF_VOICEVIEW /* VoiceView Services W95 only */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   767
# ifdef AF_VOICEVIEW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   768
#  ifndef PF_VOICEVIEW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   769
#   define PF_VOICEVIEW AF_VOICEVIEW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   770
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   771
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   772
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   773
# undef AF_VOICEVIEW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   774
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   775
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   776
#ifdef WANT__AF_IRDA /* infrared */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   777
# ifdef AF_IRDA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   778
#  ifndef PF_IRDA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   779
#   define PF_IRDA AF_IRDA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   780
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   781
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   782
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   783
# undef AF_IRDA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   784
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   785
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   786
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   787
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   788
 * now, include what we have to ...
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   789
 * undef support, if no include file is present
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   790
 * (or I dont know yet, where to find it)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   791
 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   792
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   793
#ifdef AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   794
# ifdef UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   795
#  include <sys/un.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   796
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   797
#  undef AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   798
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   799
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   800
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   801
#ifdef AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   802
# include <netdb.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   803
# if defined(PRE_SUSE_7_2)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   804
#  if defined(LINUX) && defined(AF_INET6)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   805
#   include <linux/in.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   806
#  else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   807
#   include <netinet/in.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   808
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   809
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   810
#  include <netinet/in.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   811
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   812
# if !defined(LINUX)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   813
#  if ! (defined(SYSV3) && defined(mc88k))
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   814
#   include <netinet/tcp.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   815
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   816
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   817
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   818
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   819
#ifdef AF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   820
# if defined(LINUX) && defined(__GLIBC__)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   821
#  if defined(PRE_SUSE_7_2)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   822
#   include <linux/in6.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   823
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   824
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   825
#  undef AF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   826
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   827
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   828
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   829
#ifdef AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   830
# ifdef LINUX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   831
#  include <asm/types.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   832
#  include <linux/atalk.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   833
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   834
#  undef AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   835
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   836
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   837
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   838
#ifdef AF_DECNET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   839
# ifdef solaris2_0
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   840
#  include <X11/dni8.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   841
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   842
#  undef AF_DECNET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   843
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   844
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   845
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   846
#ifdef AF_X25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   847
# ifdef LINUX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   848
#  include <linux/x25.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   849
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   850
#  undef AF_X25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   851
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   852
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   853
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   854
#ifdef AF_AX25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   855
# ifdef LINUX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   856
#  include <linux/ax25.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   857
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   858
#  undef AF_AX25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   859
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   860
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   861
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   862
#ifdef AF_IPX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   863
# ifdef LINUX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   864
#  include <linux/ipx.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   865
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   866
#  ifdef WIN32
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   867
#   include <wsipx.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   868
#  else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   869
#   undef AF_IPX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   870
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   871
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   872
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   873
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   874
#ifdef AF_NETBIOS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   875
# ifdef WIN32
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   876
#  include <wsnetbs.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   877
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   878
#  undef AF_NETBIOS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   879
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   880
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   881
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   882
#ifdef AF_ATM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   883
# ifdef WIN32
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   884
#  include <ws2atm.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   885
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   886
#  undef AF_ATM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   887
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   888
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   889
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   890
#ifdef AF_BAN
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   891
# ifdef WIN32
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   892
#  include <wsvns.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   893
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   894
#  undef AF_BAN
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   895
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   896
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   897
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   898
#ifdef AF_VOICEVIEW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   899
# ifdef WIN32
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   900
#  include <wsvv.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   901
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   902
#  undef AF_VOICEVIEW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   903
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   904
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   905
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   906
#ifdef AF_IRDA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   907
# ifdef LINUX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   908
#  include <linux/irda.h>
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   909
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   910
#  undef AF_IRDA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   911
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   912
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   913
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   914
#ifdef NET_IF_SUPPORT  /* for mac address of interfaces */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   915
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   916
# ifndef _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   917
#  include <net/if.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   918
#  define _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   919
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   920
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   921
# ifndef _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   922
#  include <sys/ioctl.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   923
#  define _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   924
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   925
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   926
#endif /* NET_IF_SUPPORT */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   927
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   928
#undef AF_SNA     /* not yet implemented */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   929
#undef AF_RAW     /* not yet implemented */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   930
#undef AF_NETROM  /* not yet implemented */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   931
#undef AF_BRIDGE  /* not yet implemented */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   932
#undef AF_BSC     /* not yet implemented */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   933
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   934
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   935
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   936
 * see what is leftOver
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   937
 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   938
union sockaddr_u {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   939
#ifdef AF_UNIX
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   940
	struct sockaddr_un un;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   941
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   942
#ifdef AF_INET
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   943
	struct sockaddr_in in;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   944
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   945
#ifdef AF_INET6
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   946
	struct sockaddr_in6 in6;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   947
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   948
#ifdef AF_APPLETALK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   949
	struct sockaddr_at at;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   950
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   951
#ifdef AF_DECNET
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   952
	struct sockaddr_dn dn;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   953
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   954
#ifdef AF_X25
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   955
	struct sockaddr_x25 x25;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   956
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   957
#ifdef AF_AX25
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   958
	struct sockaddr_ax25 ax25;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   959
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   960
#ifdef AF_IPX
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   961
	struct sockaddr_ipx ipx;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   962
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   963
#ifdef AF_NETBIOS
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   964
	struct sockaddr_nb nb;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   965
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   966
#ifdef AF_ATM
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   967
	struct sockaddr_atm atm;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   968
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   969
#ifdef AF_BAN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   970
	struct sockaddr_vns vns;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   971
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   972
#ifdef AF_VOICEVIEW
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   973
	struct sockaddr_vv vv;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   974
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   975
#ifdef AF_IRDA
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
   976
	struct sockaddr_irda irda;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   977
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   978
};
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   979
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   980
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   981
#if defined(TRY_AGAIN) || defined(HOST_NOT_FOUND)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   982
# define USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   983
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   984
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   985
#ifdef USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   986
# ifndef h_errno
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   987
 extern h_errno;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   988
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   989
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   990
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   991
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   992
 * gethostbyname seems to have trouble
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   993
 * sometimes, if interrupted while a request
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   994
 * is on its way the name server.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   995
 * (although specified in the man-page, 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   996
 * a check on TRY_AGAIN fails on iris)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   997
 */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   998
#ifdef LINUX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   999
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1000
# define GETHOSTBYNAME(hp, name) \
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1001
	hp = gethostbyname((char *) name);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1002
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1003
# define GETHOSTBYADDR(hp, addr, alen, af) \
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1004
	hp = gethostbyaddr(addr, alen, af);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1005
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1006
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1007
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1008
# ifdef IRIX5_3
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1009
#  define GETHOSTBYNAME(hp, name) \
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1010
	do { \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1011
	    __BEGIN_INTERRUPTABLE__  \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1012
	    hp = gethostbyname((char *) name); \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1013
	    __END_INTERRUPTABLE__ \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1014
	} while ((hp == NULL) && \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1015
		 ((h_errno == TRY_AGAIN) || (errno == ECONNREFUSED)));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1016
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1017
#  define GETHOSTBYADDR(hp, addr, alen, af) \
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1018
	do { \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1019
	    __BEGIN_INTERRUPTABLE__ \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1020
	    hp = gethostbyaddr(addr, alen, af); \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1021
	    __END_INTERRUPTABLE__ \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1022
	} while ((hp == NULL) && \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1023
		((h_errno == TRY_AGAIN) || (errno == ECONNREFUSED)));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1024
# else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1025
#  ifdef USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1026
#   define GETHOSTBYNAME(hp, name) \
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1027
	do { \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1028
	    __BEGIN_INTERRUPTABLE__  \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1029
	    hp = gethostbyname((char *) name); \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1030
	    __END_INTERRUPTABLE__ \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1031
	} while ((hp == NULL) && (h_errno == TRY_AGAIN));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1032
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1033
#   define GETHOSTBYADDR(hp, addr, alen, af) \
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1034
	do { \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1035
	    __BEGIN_INTERRUPTABLE__  \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1036
	    hp = gethostbyaddr(addr, alen, af); \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1037
	    __END_INTERRUPTABLE__ \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1038
	} while ((hp == NULL) && (h_errno == TRY_AGAIN));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1039
#  else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1040
#   define GETHOSTBYNAME(hp, name) \
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1041
	__BEGIN_INTERRUPTABLE__  \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1042
	hp = gethostbyname((char *) name); \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1043
	__END_INTERRUPTABLE__ 
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1044
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1045
#   define GETHOSTBYADDR(hp, addr, alen, af) \
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1046
	__BEGIN_INTERRUPTABLE__ \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1047
	hp = gethostbyaddr(addr, alen, af); \
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  1048
	__END_INTERRUPTABLE__
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1049
#  endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1050
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1051
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1052
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1053
#ifdef DEBUG
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1054
# define DBGPRINTF(x)    { if (__debugging__) printf x; }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1055
# define DBGFPRINTF(x)   { if (__debugging__) fprintf x; }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1056
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1057
# define DBGPRINTF(x)    /* as nothing */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1058
# define DBGFPRINTF(x)   /* as nothing */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1059
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  1060
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
!UnixOperatingSystem primitiveFunctions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
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
 * 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
  1069
 * 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
  1070
 * (LINUX is one of them)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
 * 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
  1072
 * UnixOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
 * 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
  1074
 *
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
 * 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
  1076
 * 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
  1077
 * (i.e. it is RT safe)
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
#if defined(WANT_SYSTEM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
/* # define DPRINTF(x)     printf x */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
# define DPRINTF(x)     /* nothing */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
# ifndef _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
#  include <stddef.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
#  define _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
# endif
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
# ifndef _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
#  include <stdlib.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
#  define _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
# ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
#  include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
#  define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
# endif
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
# ifndef _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
#  define _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
# ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
#  include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
#  define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
# 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
  1116
#  define       __environ       environ
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  1117
#  if 1 /* !defined(LINUX) */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
#   define      __sigemptyset   sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
#   define      __sigaction     sigaction
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
#   define      __sigaddset     sigaddset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
#   define      __sigprocmask   sigprocmask
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
#   define      __execve        execve
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
#   define      __wait          wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
#   define      __waitpid       waitpid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
#   if defined(HAS_VFORK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
#    define     FORK            vfork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
#    define     FORK            fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
#  endif /* ! LINUX */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
   extern char **environ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  1134
# define      __sigprocmask   sigprocmask
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  1135
# define      __execve        execve
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
  1136
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
# 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
  1138
# define        SHELL_NAME      "sh"            /* Name to give it.  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
# ifndef        FORK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
#  define       FORK    __fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
# endif
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
static int
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
mySystem(line)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
    register CONST char *line;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
    int status, save;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
    pid_t pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
    struct sigaction sa, intr, quit;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
    sigset_t block, omask;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
    if (line == NULL)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1154
	return -1;
3496
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
    sa.sa_handler = SIG_IGN;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
    sa.sa_flags = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
    __sigemptyset (&sa.sa_mask);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1161
	DPRINTF(("1: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1162
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1165
	save = errno;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1166
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1167
	errno = save;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1168
	DPRINTF(("2: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1169
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
    __sigemptyset (&block);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
    __sigaddset (&block, SIGCHLD);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1176
	if (errno == ENOSYS)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1177
	    errno = save;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1178
	else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1179
	    save = errno;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1180
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1181
	    (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1182
	    errno = save;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1183
	    DPRINTF(("3: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1184
	    return -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1185
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1187
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
    pid = FORK ();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
    if (pid == (pid_t) 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1190
	/* Child side.  */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1191
	CONST char *new_argv[4];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1192
	new_argv[0] = SHELL_NAME;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1193
	new_argv[1] = "-c";
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1194
	new_argv[2] = line;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1195
	new_argv[3] = NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1196
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1197
	/* Restore the signals.  */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1198
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1199
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1200
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1201
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1202
	/* Exec the shell.  */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1203
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1204
	_exit (127);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1206
	if (pid < (pid_t) 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1207
	    /* The fork failed.  */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1208
	    DPRINTF(("4: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1209
	    status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1210
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1211
	    /* Parent side.  */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
#ifdef  NO_WAITPID
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1213
	    pid_t child;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1214
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1215
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1216
		__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1217
		child = __wait (&status);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1218
		__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1219
		if (child < 0 && errno != EINTR) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1220
		    DPRINTF(("5: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1221
		    status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1222
		    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1223
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1224
	    } while (child != pid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
#else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1226
	    pid_t child;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1227
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1228
	    /* claus: the original did not care for EINTR here ... */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1229
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1230
		__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1231
		child = __waitpid (pid, &status, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1232
		__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1233
	    } while ((child != pid) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1234
	    if (child != pid) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1235
		DPRINTF(("6: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1236
		status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1237
	    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
#endif /* NO_WAITPID */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1239
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1241
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1245
	if (errno == ENOSYS) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1246
	    errno = save;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1247
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1248
	    status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1249
	    DPRINTF(("7: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1250
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1253
    return status;
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
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1256
# define __wait wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1257
#endif /* WANT_SYSTEM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
 * some systems do not have realpath();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
 * the alternative of reading from a 'pwp'-pipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
 * 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
  1264
 * 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
  1265
 */
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
#if defined(HAS_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1268
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1269
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1274
#if defined(WANT_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1275
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1276
# ifndef NULL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1277
#  define NULL (char *)0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1278
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1279
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1280
# define MAX_READLINKS 32
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1281
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
# ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
#  define MAXPATHLEN     1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1286
static
6357
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
  1287
char *
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
  1288
realpath(path, resolved_path)
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
  1289
    char *path;
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
  1290
    char resolved_path [];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
{
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1292
	char copy_path[MAXPATHLEN];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1293
	char link_path[MAXPATHLEN];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1294
	char *new_path = resolved_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1295
	char *max_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1296
	int readlinks = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1297
	int n;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1298
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1299
	/* Make a copy of the source path since we may need to modify it. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1300
	strcpy(copy_path, path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1301
	path = copy_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1302
	max_path = copy_path + MAXPATHLEN - 2;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1303
	/* If it's a relative pathname use getwd for starters. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1304
	if (*path != '/') {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
#ifdef HAS_GETCWD
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1306
		new_path = getcwd(new_path, MAXPATHLEN - 1);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
#else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1308
		new_path = getwd(new_path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1309
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1310
		if (new_path == NULL) 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1311
		    return(NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1312
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1313
		new_path += strlen(new_path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1314
		if (new_path[-1] != '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1315
			*new_path++ = '/';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1316
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1317
	else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1318
		*new_path++ = '/';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1319
		path++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1320
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1321
	/* Expand each slash-separated pathname component. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1322
	while (*path != '\0') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1323
		/* Ignore stray "/". */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1324
		if (*path == '/') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1325
			path++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1326
			continue;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1327
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1328
		if (*path == '.') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1329
			/* Ignore ".". */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1330
			if (path[1] == '\0' || path[1] == '/') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1331
				path++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1332
				continue;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1333
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1334
			if (path[1] == '.') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1335
				if (path[2] == '\0' || path[2] == '/') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1336
					path += 2;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1337
					/* Ignore ".." at root. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1338
					if (new_path == resolved_path + 1)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1339
						continue;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1340
					/* Handle ".." by backing up. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1341
					while ((--new_path)[-1] != '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1342
						;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1343
					continue;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1344
				}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1345
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1346
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1347
		/* Safely copy the next pathname component. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1348
		while (*path != '\0' && *path != '/') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1349
			if (path > max_path) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1350
				errno = ENAMETOOLONG;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1351
				return NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1352
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1353
			*new_path++ = *path++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1354
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
#ifdef S_IFLNK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1356
		/* Protect against infinite loops. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1357
		if (readlinks++ > MAX_READLINKS) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1358
			errno = ELOOP;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1359
			return NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1360
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1361
		/* See if latest pathname component is a symlink. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1362
		*new_path = '\0';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1363
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1364
		if (n < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1365
			/* EINVAL means the file exists but isn't a symlink. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1366
			if (errno != EINVAL)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1367
				return NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1368
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1369
		else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1370
			/* Note: readlink doesn't add the null byte. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1371
			link_path[n] = '\0';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1372
			if (*link_path == '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1373
				/* Start over for an absolute symlink. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1374
				new_path = resolved_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1375
			else
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1376
				/* Otherwise back up over this component. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1377
				while (*(--new_path) != '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1378
					;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1379
			/* Safe sex check. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1380
			if (strlen(path) + n >= MAXPATHLEN) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1381
				errno = ENAMETOOLONG;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1382
				return NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1383
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1384
			/* Insert symlink contents into path. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1385
			strcat(link_path, path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1386
			strcpy(copy_path, link_path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1387
			path = copy_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1388
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
#endif /* S_IFLNK */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1390
		*new_path++ = '/';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1391
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1392
	/* Delete trailing slash but don't whomp a lone slash. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1393
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1394
		new_path--;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1395
	/* Make sure it's null terminated. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1396
	*new_path = '\0';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1397
	return resolved_path;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
# define HAS_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1400
#endif /* WANT_REALPATH && not HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1401
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1402
%}
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
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1406
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
copyright
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1408
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1409
 COPYRIGHT (c) 1988 by Claus Gittinger
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1410
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1411
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1412
 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
  1413
 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
  1414
 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
  1415
 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
  1416
 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
  1417
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1422
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
    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
  1424
    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
  1425
    things available here in your applications 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1426
    - 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
  1427
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
    (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
  1429
     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
  1430
     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
  1431
     You decide - portability vs. functionality)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
    [Class variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1435
	HostName        <String>        remembered hostname
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1436
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1437
	DomainName      <String>        remembered domainname
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1438
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1439
	SlowFork        <Boolean>       if set, fork and popen are avoided;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1440
					(more or less obsolete now)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1441
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1442
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1443
	CurrentDirectory <String>       remembered currentDirectories path
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
    [author:]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1446
	Claus Gittinger
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
    [see also:]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1449
	OSProcessStatus
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1450
	Filename Date Time
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1451
	ExternalStream FileStream PipeStream Socket
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
examples
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
  various queries
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1458
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
    Transcript 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1460
	showCR:'hello ' , (OperatingSystem getLoginName)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1461
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1462
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1463
								[exBegin]
3793
aff27e755ffd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  1464
    OperatingSystem isUNIXlike ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1465
	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
  1466
    ] ifFalse:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1467
	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
  1468
    ]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1469
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1470
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1471
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
    Transcript 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1473
	showCR:'this machine is called ' , OperatingSystem getHostName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1474
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1475
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1476
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1477
    Transcript 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1478
	showCR:('this machine is in the '
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1479
	       , OperatingSystem getDomainName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1480
	       , ' domain')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1481
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1482
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1483
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
    Transcript 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1485
	showCR:('this machine''s CPU is a '
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1486
	       , OperatingSystem getCPUType
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1487
	       )
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1488
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1489
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1490
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
    Transcript showCR:'executing ls command ...'.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  1492
    OperatingSystem executeCommand:'ls'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
    Transcript showCR:'... done.'.
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1494
								[exEnd]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
  locking a file 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
  (should be executed on two running smalltalks - not in two threads):
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1498
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
    |f|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
    f := 'testFile' asFilename readWriteStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
    10 timesRepeat:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1504
	'about to lock ...' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1505
	[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1506
	  OperatingSystem 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1507
	    lockFD:(f fileDescriptor)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1508
	    shared:false
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1509
	    blocking:false
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1510
	] whileFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1511
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1512
	    Delay waitForSeconds:1
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1513
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1514
	'LOCKED ...' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1515
	Delay waitForSeconds:10.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1516
	'unlock ...' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1517
	(OperatingSystem 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1518
	    unlockFD:(f fileDescriptor)) printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1519
	Delay waitForSeconds:3.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
    ]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1521
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1523
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1524
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1525
!UnixOperatingSystem class methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1526
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1527
initialize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1528
    "initialize the class"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1529
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1530
    ObjectMemory addDependent:self.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1531
    HostName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1532
    DomainName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1533
    LastErrorNumber := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1534
    PipeFailed := false.
4395
53122eb3ce70 clear ForkFailed flag; made it a classVar
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1535
    ForkFailed := false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1536
    SlowFork := false.
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1537
    CurrentDirectory := nil.
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1538
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1539
    "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
  1540
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1541
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1542
update:something with:aParameter from:changedObject
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1543
    "catch image restart and flush some cached data"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1544
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1545
    something == #earlyRestart ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1546
	"
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1547
	 flush cached data/info
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1548
	"
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1549
	HostName := nil.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1550
	DomainName := nil.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1551
	LastErrorNumber := nil.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1552
	PipeFailed := false.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1553
	SlowFork := false.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1554
	ForkFailed := false.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1555
	CurrentDirectory := nil.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1556
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1558
    "Created: / 15.6.1996 / 15:22:37 / cg"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1559
    "Modified: / 7.1.1997 / 19:36:11 / stefan"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1560
    "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
  1561
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1562
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
!UnixOperatingSystem class methodsFor:'OS signal constants'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1564
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1565
sigABRT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1566
    "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
  1567
     (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
  1568
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1569
    ^ self signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1570
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1571
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1572
     OperatingSystem sigABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1573
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1575
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1576
sigALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1577
    "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
  1578
     (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
  1579
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1580
    ^ self signalNamed:#SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1581
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1582
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1583
     OperatingSystem sigALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1584
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
sigBREAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
    "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
  1589
     This is an MSDOS specific signal"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1590
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1591
    ^ self signalNamed:#SIGBREAK
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
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1594
     OperatingSystem sigBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1595
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1596
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1597
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
sigBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
    "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
  1600
     (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
  1601
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1602
    ^ self signalNamed:#SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1603
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1604
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1605
     OperatingSystem sigBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1606
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1607
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1608
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
sigCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
    "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
  1611
     (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
  1612
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1613
    ^ self signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1614
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1615
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1616
     OperatingSystem sigCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1617
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1619
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
sigCONT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1621
    "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
  1622
     (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
  1623
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1624
    ^ self signalNamed:#SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1625
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1626
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1627
     OperatingSystem sigCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1628
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1630
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1631
sigDANGER
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
    "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
  1633
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1635
    ^ self signalNamed:#SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1636
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1637
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1638
     OperatingSystem sigDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1639
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1640
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1641
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1642
sigEMT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1643
    "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
  1644
     (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
  1645
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1646
    ^ self signalNamed:#SIGEMT
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
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1649
     OperatingSystem sigEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1650
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1651
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1652
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1653
sigFP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1654
    "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
  1655
     (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
  1656
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1657
    ^ self signalNamed:#SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1658
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1659
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1660
     OperatingSystem sigFP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1661
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1662
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1663
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1664
sigGRANT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1665
    "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
  1666
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1667
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1668
    ^ self signalNamed:#SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1669
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1670
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1671
     OperatingSystem sigGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1672
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1673
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1674
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1675
sigHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1676
    "return the signal number for SIGHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1677
     (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
  1678
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1679
    ^ self signalNamed:#SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1680
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1681
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1682
     OperatingSystem sigHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1683
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1684
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1685
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1686
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1687
sigILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1688
    "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
  1689
     (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
  1690
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1691
    ^ self signalNamed:#SIGILL
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
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1694
     OperatingSystem sigILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1695
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1696
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1697
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1698
sigINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1699
    "return the signal number for SIGINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
     (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
  1701
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1702
    ^ self signalNamed:#SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1703
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1704
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1705
     OperatingSystem sigINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1706
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1707
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1708
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1709
sigIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1710
    "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
  1711
     (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
  1712
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1713
    ^ self signalNamed:#SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1714
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1715
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1716
     OperatingSystem sigIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1717
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1718
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1719
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1720
sigIOT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1721
    "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
  1722
     (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
  1723
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1724
    ^ self signalNamed:#SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1725
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1726
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1727
     OperatingSystem sigIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1728
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1729
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1730
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1731
sigKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
    "return the signal number for SIGKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1733
     (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
  1734
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1735
    ^ self signalNamed:#SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1736
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
     OperatingSystem sigKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1739
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1740
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1741
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
sigLOST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1743
    "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
  1744
     (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
  1745
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1746
    ^ self signalNamed:#SIGLOST
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
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1749
     OperatingSystem sigLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1750
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1753
sigMIGRATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
    "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
  1755
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1757
    ^ self signalNamed:#SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1758
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1759
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1760
     OperatingSystem sigMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1761
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1762
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1763
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1764
sigMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
    "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
  1766
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1768
    ^ self signalNamed:#SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1769
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1770
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1771
     OperatingSystem sigMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1772
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1774
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1775
sigPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1776
    "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
  1777
     (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
  1778
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1779
    ^ self signalNamed:#SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1780
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1781
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1782
     OperatingSystem sigPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1783
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1784
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1785
!
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
sigPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1788
    "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
  1789
     (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
  1790
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1791
    ^ self signalNamed:#SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1792
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1793
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1794
     OperatingSystem sigPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1795
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1797
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1798
sigPRE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1799
    "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
  1800
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1802
    ^ self signalNamed:#SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1803
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1804
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1805
     OperatingSystem sigPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1806
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1807
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1808
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
sigPROF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
    "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
  1811
     (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
  1812
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1813
    ^ self signalNamed:#SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1814
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1815
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1816
     OperatingSystem sigPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1817
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1818
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1819
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1820
sigPWR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1821
    "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
  1822
     (not available on all systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1823
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1824
    ^ self signalNamed:#SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1825
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1826
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1827
     OperatingSystem sigPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1828
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1829
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1830
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1831
sigQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1832
    "return the signal number for SIGQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1833
     (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
  1834
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1835
    ^ self signalNamed:#SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1836
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1837
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1838
     OperatingSystem sigQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1839
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1840
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1841
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1842
sigRETRACT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1843
    "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
  1844
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1845
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1846
    ^ self signalNamed:#SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1847
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1848
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1849
     OperatingSystem sigRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1850
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1851
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1852
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1853
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1854
sigSAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1855
    "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
  1856
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1857
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1858
    ^ self signalNamed:#SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1859
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1860
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1861
     OperatingSystem sigSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1862
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1863
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1864
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1866
sigSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1867
    "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
  1868
     (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
  1869
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1870
    ^ self signalNamed:#SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1871
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1872
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1873
     OperatingSystem sigSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1874
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1875
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1876
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1877
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1878
sigSOUND
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1879
    "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
  1880
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1881
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1882
    ^ self signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1883
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1884
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1885
     OperatingSystem sigSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1886
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1887
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1888
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1889
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1890
sigSTOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1891
    "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
  1892
     (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
  1893
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1894
    ^ self signalNamed:#SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1895
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1896
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1897
     OperatingSystem sigSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1898
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1899
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1900
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1901
sigSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1902
    "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
  1903
     (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
  1904
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1905
    ^ self signalNamed:#SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1906
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1907
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1908
     OperatingSystem sigSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1909
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1910
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1911
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1912
sigTERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1913
    "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
  1914
     (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
  1915
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1916
    ^ self signalNamed:#SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1917
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1918
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1919
     OperatingSystem sigTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1920
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1921
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1922
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1923
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1924
sigTRAP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1925
    "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
  1926
     (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
  1927
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1928
    ^ self signalNamed:#SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1929
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1930
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1931
     OperatingSystem sigTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1932
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1933
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1934
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1935
sigTSTP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1936
    "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
  1937
     (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
  1938
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1939
    ^ self signalNamed:#SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1940
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1941
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1942
     OperatingSystem sigTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1943
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1944
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1945
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1946
sigTTIN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1947
    "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
  1948
     (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
  1949
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1950
    ^ self signalNamed:#SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1951
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1952
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1953
     OperatingSystem sigTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1954
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1955
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1956
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1957
sigTTOU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1958
    "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
  1959
     (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
  1960
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1961
    ^ self signalNamed:#SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1962
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1963
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1964
     OperatingSystem sigTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1965
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1966
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1967
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1968
sigURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1969
    "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
  1970
     (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
  1971
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1972
    ^ self signalNamed:#SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1973
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1974
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1975
     OperatingSystem sigURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1976
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1977
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1978
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1979
sigUSR1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1980
    "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
  1981
     (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
  1982
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1983
    ^ self signalNamed:#SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1984
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1985
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1986
     OperatingSystem sigUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1987
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1988
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1989
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1990
sigUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1991
    "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
  1992
     (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
  1993
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1994
    ^ self signalNamed:#SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1995
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1996
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1997
     OperatingSystem sigUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1998
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1999
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2000
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2001
sigVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2002
    "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
  2003
     (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
  2004
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2005
    ^ self signalNamed:#SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2006
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2007
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2008
     OperatingSystem sigVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2009
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2010
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2011
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2012
sigWINCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2013
    "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
  2014
     (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
  2015
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2016
    ^ self signalNamed:#SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2017
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2018
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2019
     OperatingSystem sigWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2020
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2021
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2022
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2023
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2024
sigXCPU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2025
    "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
  2026
     (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
  2027
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2028
    ^ self signalNamed:#SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2029
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2030
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2031
     OperatingSystem sigXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2032
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2033
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2034
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2035
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2036
sigXFSZ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2037
    "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
  2038
     (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
  2039
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2040
    ^ self signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2041
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2042
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2043
     OperatingSystem sigXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2044
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2045
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2046
!
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2047
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2048
signalNamed:signalName
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2049
    "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
  2050
     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
  2051
     (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
  2052
      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
  2053
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2054
%{  /* NOCONTEXT */
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2055
#ifdef SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2056
    if (signalName == @symbol(SIGABRT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2057
	RETURN ( __MKSMALLINT(SIGABRT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2058
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2059
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2060
#ifdef SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2061
    if (signalName == @symbol(SIGALRM)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2062
	RETURN ( __MKSMALLINT(SIGALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2063
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2064
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2065
#ifdef SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2066
    if (signalName == @symbol(SIGBREAK)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2067
	RETURN ( __MKSMALLINT(SIGBREAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2068
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2069
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2070
#ifdef SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2071
    if (signalName == @symbol(SIGBUS)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2072
	RETURN ( __MKSMALLINT(SIGBUS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2073
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2074
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2075
#ifdef SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2076
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2077
     || (signalName == @symbol(SIGCLD)) ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2078
	RETURN ( __MKSMALLINT(SIGCHLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2079
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2080
#else
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2081
# if defined(SIGCLD)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2082
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2083
     || (signalName == @symbol(SIGCLD)) ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2084
	RETURN ( __MKSMALLINT(SIGCLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2085
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2086
# endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2087
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2088
#ifdef SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2089
    if (signalName == @symbol(SIGCONT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2090
	RETURN ( __MKSMALLINT(SIGCONT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2091
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2092
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2093
#ifdef SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2094
    if (signalName == @symbol(SIGDANGER)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2095
	RETURN ( __MKSMALLINT(SIGDANGER) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2096
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2097
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2098
#ifdef SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2099
    if (signalName == @symbol(SIGEMT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2100
	RETURN ( __MKSMALLINT(SIGEMT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2101
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2102
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2103
#ifdef SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2104
    if (signalName == @symbol(SIGFPE)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2105
	RETURN ( __MKSMALLINT(SIGFPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2106
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2107
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2108
#ifdef SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2109
    if (signalName == @symbol(SIGGRANT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2110
	RETURN ( __MKSMALLINT(SIGGRANT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2111
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2112
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2113
#ifdef SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2114
    if (signalName == @symbol(SIGHUP)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2115
	RETURN ( __MKSMALLINT(SIGHUP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2116
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2117
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2118
#ifdef SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2119
    if (signalName == @symbol(SIGILL)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2120
	RETURN ( __MKSMALLINT(SIGILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2121
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2122
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2123
#ifdef SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2124
    if (signalName == @symbol(SIGINT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2125
	RETURN ( __MKSMALLINT(SIGINT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2126
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2127
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2128
#ifdef SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2129
    if (signalName == @symbol(SIGIO)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2130
	RETURN ( __MKSMALLINT(SIGIO) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2131
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2132
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2133
#ifdef SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2134
    if (signalName == @symbol(SIGIOT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2135
	RETURN ( __MKSMALLINT(SIGIOT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2136
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2137
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2138
#ifdef SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2139
    if (signalName == @symbol(SIGKILL)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2140
	RETURN ( __MKSMALLINT(SIGKILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2141
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2142
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2143
#ifdef SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2144
    if (signalName == @symbol(SIGLOST)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2145
	RETURN ( __MKSMALLINT(SIGLOST) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2146
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2147
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2148
#ifdef SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2149
    if (signalName == @symbol(SIGMIGRATE)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2150
	RETURN ( __MKSMALLINT(SIGMIGRATE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2151
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2152
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2153
#ifdef SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2154
    if (signalName == @symbol(SIGMSG)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2155
	RETURN ( __MKSMALLINT(SIGMSG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2156
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2157
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2158
#ifdef SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2159
    if (signalName == @symbol(SIGPIPE)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2160
	RETURN ( __MKSMALLINT(SIGPIPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2161
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2162
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2163
#ifdef SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2164
    if (signalName == @symbol(SIGPOLL)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2165
	RETURN ( __MKSMALLINT(SIGPOLL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2166
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2167
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2168
#ifdef SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2169
    if (signalName == @symbol(SIGPRE)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2170
	RETURN ( __MKSMALLINT(SIGPRE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2171
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2172
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2173
#ifdef SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2174
    if (signalName == @symbol(SIGPROF)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2175
	RETURN ( __MKSMALLINT(SIGPROF) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2176
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2177
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2178
#ifdef SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2179
    if (signalName == @symbol(SIGPWR)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2180
	RETURN ( __MKSMALLINT(SIGPWR) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2181
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2182
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2183
#ifdef SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2184
    if (signalName == @symbol(SIGQUIT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2185
	RETURN ( __MKSMALLINT(SIGQUIT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2186
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2187
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2188
#ifdef SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2189
    if (signalName == @symbol(SIGRETRACT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2190
	RETURN ( __MKSMALLINT(SIGRETRACT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2191
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2192
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2193
#ifdef SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2194
    if (signalName == @symbol(SIGSAK)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2195
	RETURN ( __MKSMALLINT(SIGSAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2196
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2197
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2198
#ifdef SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2199
    if (signalName == @symbol(SIGSEGV)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2200
	RETURN ( __MKSMALLINT(SIGSEGV) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2201
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2202
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2203
#ifdef SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2204
    if (signalName == @symbol(SIGSOUND)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2205
	RETURN ( __MKSMALLINT(SIGSOUND) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2206
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2207
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2208
#ifdef SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2209
    if (signalName == @symbol(SIGSTOP)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2210
	RETURN ( __MKSMALLINT(SIGSTOP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2211
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2212
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2213
#ifdef SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2214
    if (signalName == @symbol(SIGSYS)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2215
	RETURN ( __MKSMALLINT(SIGSYS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2216
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2217
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2218
#ifdef SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2219
    if (signalName == @symbol(SIGTERM)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2220
	RETURN ( __MKSMALLINT(SIGTERM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2221
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2222
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2223
#ifdef SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2224
    if (signalName == @symbol(SIGTRAP)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2225
	RETURN ( __MKSMALLINT(SIGTRAP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2226
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2227
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2228
#ifdef SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2229
    if (signalName == @symbol(SIGTSTP)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2230
	RETURN ( __MKSMALLINT(SIGTSTP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2231
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2232
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2233
#ifdef SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2234
    if (signalName == @symbol(SIGTTIN)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2235
	RETURN ( __MKSMALLINT(SIGTTIN) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2236
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2237
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2238
#ifdef SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2239
    if (signalName == @symbol(SIGTTOU)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2240
	RETURN ( __MKSMALLINT(SIGTTOU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2241
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2242
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2243
#ifdef SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2244
    if (signalName == @symbol(SIGURG)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2245
	RETURN ( __MKSMALLINT(SIGURG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2246
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2247
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2248
#ifdef SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2249
    if (signalName == @symbol(SIGUSR1)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2250
	RETURN ( __MKSMALLINT(SIGUSR1) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2251
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2252
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2253
#ifdef SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2254
    if (signalName == @symbol(SIGUSR2)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2255
	RETURN ( __MKSMALLINT(SIGUSR2) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2256
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2257
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2258
#ifdef SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2259
    if (signalName == @symbol(SIGVTALRM)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2260
	RETURN ( __MKSMALLINT(SIGVTALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2261
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2262
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2263
#ifdef SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2264
    if (signalName == @symbol(SIGWINCH)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2265
	RETURN ( __MKSMALLINT(SIGWINCH) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2266
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2267
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2268
#ifdef SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2269
    if (signalName == @symbol(SIGXCPU)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2270
	RETURN ( __MKSMALLINT(SIGXCPU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2271
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2272
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2273
#ifdef SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2274
    if (signalName == @symbol(SIGXFSZ)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2275
	RETURN ( __MKSMALLINT(SIGXFSZ) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2276
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2277
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2278
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2279
    RETURN ( __MKSMALLINT(0) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2280
%}
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2281
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2282
     OperatingSystem signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2283
     OperatingSystem signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2284
     OperatingSystem signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2285
     OperatingSystem signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  2286
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2287
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2288
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2289
!UnixOperatingSystem class methodsFor:'error messages'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2290
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2291
currentErrorNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2292
    "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
  2293
     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
  2294
     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
  2295
     request to the OS.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2296
     Use lastErrorNumber - currentErrorNumber is invalidated by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2297
     many, many internal calls."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2298
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2299
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2300
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2301
     RETURN ( __MKSMALLINT(errno) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2302
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2303
     "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  2304
      OperatingSystem currentErrorNumber
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2305
     "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2306
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2307
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2308
errorHolderForNumber:errNr
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2309
    "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
  2310
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2311
    |sym typ holder|
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2312
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2313
%{
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2314
    /* claus:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2315
     * I made this primitive code, since errnos are not
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2316
     * standard across unixes
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
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2319
    typ = @symbol(defaultOsErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2320
    sym = @symbol(ERROR_OTHER);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2321
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2322
    if (__isSmallInteger(errNr)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2323
	switch ( __intVal(errNr)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2324
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2325
	     * POSIX errnos - these should be defined
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2326
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2327
#ifdef EPERM
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2328
	    case EPERM:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2329
		sym = @symbol(EPERM);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2330
		typ = @symbol(noPermissionsSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2331
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2332
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2333
#ifdef ENOENT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2334
	    case ENOENT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2335
		sym = @symbol(ENOENT);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2336
		typ = @symbol(nonexistentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2337
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2338
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2339
#ifdef ESRCH
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2340
	    case ESRCH:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2341
		sym = @symbol(ESRCH);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2342
		typ = @symbol(unavailableReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2343
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2344
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2345
#ifdef EINTR
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2346
	    case EINTR:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2347
		sym = @symbol(EINTR);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2348
		typ = @symbol(transientErrorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2349
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2350
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2351
#ifdef EIO
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2352
	    case EIO:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2353
		sym = @symbol(EIO);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2354
		typ = @symbol(transferFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2355
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2356
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2357
#ifdef ENXIO
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2358
	    case ENXIO:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2359
		sym = @symbol(ENXIO);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2360
		typ = @symbol(unavailableReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2361
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2362
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2363
#ifdef E2BIG
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2364
	    case E2BIG:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2365
		sym = @symbol(E2BIG);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2366
		typ = @symbol(invalidArgumentsSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2367
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2368
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2369
#ifdef ENOEXEC
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2370
	    case ENOEXEC:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2371
		sym = @symbol(ENOEXEC);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2372
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2373
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2374
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2375
#ifdef EBADF
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2376
	    case EBADF:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2377
		sym = @symbol(EBADF);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2378
		typ = @symbol(badAccessorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2379
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2380
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2381
#ifdef ECHILD
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2382
	    case ECHILD:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2383
		sym = @symbol(ECHILD);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2384
		typ = @symbol(informationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2385
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2386
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2387
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2388
	    case EAGAIN:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2389
		sym = @symbol(EAGAIN);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2390
		typ = @symbol(notReadySignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2391
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2392
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2393
#ifdef ENOMEM
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2394
	    case ENOMEM:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2395
		sym = @symbol(ENOMEM);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2396
		typ = @symbol(noMemorySignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2397
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2398
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2399
#ifdef EACCES
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2400
	    case EACCES:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2401
		sym = @symbol(EACCES);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2402
		typ = @symbol(noPermissionsSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2403
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2404
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2405
#ifdef EFAULT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2406
	    case EFAULT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2407
		sym = @symbol(EFAULT);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2408
		typ = @symbol(invalidArgumentsSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2409
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2410
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2411
#ifdef EBUSY
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2412
	    case EBUSY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2413
		sym = @symbol(EBUSY);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2414
		typ = @symbol(unavailableReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2415
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2416
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2417
#ifdef EEXIST
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2418
	    case EEXIST:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2419
		sym = @symbol(EEXIST);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2420
		typ = @symbol(existingReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2421
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2422
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2423
#ifdef EXDEV
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2424
	    case EXDEV:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2425
		sym = @symbol(EXDEV);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2426
		typ = @symbol(inappropriateReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2427
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2428
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2429
#ifdef ENODEV
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2430
	    case ENODEV:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2431
		sym = @symbol(ENODEV);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2432
		typ = @symbol(inaccessibleSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2433
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2434
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2435
#ifdef ENOTDIR
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2436
	    case ENOTDIR:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2437
		sym = @symbol(ENOTDIR);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2438
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2439
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2440
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2441
#ifdef EISDIR
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2442
	    case EISDIR:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2443
		sym = @symbol(EISDIR);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2444
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2445
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2446
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2447
#ifdef EINVAL
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2448
	    case EINVAL:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2449
		sym = @symbol(EINVAL);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2450
		typ = @symbol(invalidArgumentsSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2451
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2452
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2453
#ifdef ENFILE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2454
	    case ENFILE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2455
		sym = @symbol(ENFILE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2456
		typ = @symbol(noResourcesSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2457
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2458
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2459
#ifdef EMFILE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2460
	    case EMFILE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2461
		sym = @symbol(EMFILE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2462
		typ = @symbol(noResourcesSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2463
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2464
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2465
#ifdef ENOTTY
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2466
	    case ENOTTY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2467
		sym = @symbol(ENOTTY);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2468
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2469
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2470
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2471
#ifdef EFBIG
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2472
	    case EFBIG:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2473
		sym = @symbol(EFBIG);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2474
		typ = @symbol(noResourcesSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2475
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2476
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2477
#ifdef ENOSPC
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2478
	    case ENOSPC:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2479
		sym = @symbol(ENOSPC);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2480
		typ = @symbol(noResourcesSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2481
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2482
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2483
#ifdef ESPIPE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2484
	    case ESPIPE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2485
		sym = @symbol(ESPIPE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2486
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2487
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2488
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2489
#ifdef EROFS
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2490
	    case EROFS:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2491
		sym = @symbol(EROFS);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2492
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2493
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2494
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2495
#ifdef EMLINK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2496
	    case EMLINK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2497
		sym = @symbol(EMLINK);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2498
		typ = @symbol(rangeErrorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2499
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2500
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2501
#ifdef EPIPE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2502
	    case EPIPE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2503
		sym = @symbol(EPIPE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2504
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2505
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2506
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2507
#ifdef EDOM
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2508
	    case EDOM:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2509
		sym = @symbol(EDOM);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2510
		typ = @symbol(rangeErrorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2511
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2512
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2513
#ifdef ERANGE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2514
	    case ERANGE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2515
		sym = @symbol(ERANGE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2516
		typ = @symbol(rangeErrorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2517
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2518
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2519
#ifdef EDEADLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2520
# if EDEADLK != EWOULDBLOCK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2521
	    case EDEADLK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2522
		sym = @symbol(EDEADLK);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2523
		typ = @symbol(noResourcesSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2524
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2525
# endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2526
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2527
#ifdef ENAMETOOLONG
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2528
	    case ENAMETOOLONG:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2529
		sym = @symbol(ENAMETOOLONG);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2530
		typ = @symbol(rangeErrorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2531
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2532
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2533
#ifdef ENOLCK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2534
	    case ENOLCK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2535
		sym = @symbol(ENOLCK);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2536
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2537
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2538
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2539
#ifdef ENOSYS
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2540
	    case ENOSYS:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2541
		sym = @symbol(ENOSYS);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2542
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2543
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2544
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2545
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2546
	    case ENOTEMPTY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2547
		sym = @symbol(ENOTEMPTY);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2548
		typ = @symbol(inappropriateReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2549
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2550
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2551
#ifdef EILSEQ
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2552
	    case EILSEQ:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2553
		sym = @symbol(EILSEQ);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2554
		typ = @symbol(transferFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2555
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2556
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2557
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2558
	     * XPG3 errnos - defined on most systems
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2559
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2560
#ifdef ENOTBLK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2561
	    case ENOTBLK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2562
		sym = @symbol(ENOTBLK);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2563
		typ = @symbol(inappropriateReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2564
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2565
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2566
#ifdef ETXTBSY
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2567
	    case ETXTBSY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2568
		sym = @symbol(ETXTBSY);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2569
		typ = @symbol(inaccessibleSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2570
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2571
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2572
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2573
	     * some others
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2574
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2575
#ifdef EWOULDBLOCK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2576
	    case EWOULDBLOCK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2577
		sym = @symbol(EWOULDBLOCK);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2578
		typ = @symbol(notReadySignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2579
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2580
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2581
#ifdef ENOMSG
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2582
	    case ENOMSG:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2583
		sym = @symbol(ENOMSG);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2584
		typ = @symbol(noDataSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2585
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2586
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2587
#ifdef ELOOP
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2588
	    case ELOOP:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2589
		sym = @symbol(ELOOP);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2590
		typ = @symbol(rangeErrorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2591
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2592
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2593
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2594
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2595
	     * some stream errors
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2596
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2597
#ifdef ETIME
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2598
	    case ETIME:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2599
		sym = @symbol(ETIME);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2600
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2601
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2602
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2603
#ifdef ENOSR
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2604
	    case ENOSR:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2605
		sym = @symbol(ENOSR);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2606
		typ = @symbol(noResourcesSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2607
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2608
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2609
#ifdef ENOSTR
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2610
	    case ENOSTR:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2611
		sym = @symbol(ENOSTR);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2612
		typ = @symbol(inappropriateReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2613
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2614
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2615
#ifdef ECOMM
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2616
	    case ECOMM:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2617
		sym = @symbol(ECOMM);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2618
		typ = @symbol(transferFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2619
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2620
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2621
#ifdef EPROTO
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2622
	    case EPROTO:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2623
		sym = @symbol(EPROTO);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2624
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2625
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2626
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2627
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2628
	     * nfs errors
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2629
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2630
#ifdef ESTALE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2631
	    case ESTALE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2632
		sym = @symbol(ESTALE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2633
		typ = @symbol(unavailableReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2634
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2635
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2636
#ifdef EREMOTE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2637
	    case EREMOTE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2638
		sym = @symbol(EREMOTE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2639
		typ = @symbol(rangeErrorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2640
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2641
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2642
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2643
	     * some networking errors
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2644
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2645
#ifdef EINPROGRESS
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2646
	    case EINPROGRESS:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2647
		sym = @symbol(EINPROGRESS);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2648
		typ = @symbol(operationStartedSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2649
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2650
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2651
#ifdef EALREADY
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2652
	    case EALREADY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2653
		sym = @symbol(EALREADY);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2654
		typ = @symbol(operationStartedSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2655
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2656
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2657
#ifdef ENOTSOCK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2658
	    case ENOTSOCK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2659
		sym = @symbol(ENOTSOCK);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2660
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2661
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2662
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2663
#ifdef EDESTADDRREQ
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2664
	    case EDESTADDRREQ:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2665
		sym = @symbol(EDESTADDRREQ);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2666
		typ = @symbol(underspecifiedSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2667
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2668
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2669
#ifdef EMSGSIZE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2670
	    case EMSGSIZE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2671
		sym = @symbol(EMSGSIZE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2672
		typ = @symbol(rangeErrorSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2673
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2674
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2675
#ifdef EPROTOTYPE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2676
	    case EPROTOTYPE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2677
		sym = @symbol(EPROTOTYPE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2678
		typ = @symbol(wrongSubtypeForOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2679
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2680
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2681
#ifdef ENOPROTOOPT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2682
	    case ENOPROTOOPT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2683
		sym = @symbol(ENOPROTOOPT);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2684
		typ = @symbol(unsupportedOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2685
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2686
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2687
#ifdef EPROTONOSUPPORT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2688
	    case EPROTONOSUPPORT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2689
		sym = @symbol(EPROTONOSUPPORT);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2690
		typ = @symbol(unsupportedOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2691
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2692
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2693
#ifdef ESOCKTNOSUPPORT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2694
	    case ESOCKTNOSUPPORT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2695
		sym = @symbol(ESOCKTNOSUPPORT);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2696
		typ = @symbol(unsupportedOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2697
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2698
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2699
#ifdef EOPNOTSUPP
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2700
	    case EOPNOTSUPP:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2701
		sym = @symbol(EOPNOTSUPP);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2702
		typ = @symbol(inappropriateOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2703
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2704
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2705
#ifdef EPFNOSUPPORT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2706
	    case EPFNOSUPPORT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2707
		sym = @symbol(EPFNOSUPPORT);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2708
		typ = @symbol(unsupportedOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2709
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2710
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2711
#ifdef EAFNOSUPPORT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2712
	    case EAFNOSUPPORT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2713
		sym = @symbol(EAFNOSUPPORT);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2714
		typ = @symbol(unsupportedOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2715
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2716
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2717
#ifdef EADDRINUSE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2718
	    case EADDRINUSE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2719
		sym = @symbol(EADDRINUSE);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2720
		typ = @symbol(existingReferentSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2721
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2722
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2723
#ifdef EADDRNOTAVAIL
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2724
	    case EADDRNOTAVAIL:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2725
		sym = @symbol(EADDRNOTAVAIL);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2726
		typ = @symbol(noPermissionsSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2727
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2728
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2729
#ifdef ETIMEDOUT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2730
	    case ETIMEDOUT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2731
		sym = @symbol(ETIMEDOUT);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2732
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2733
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2734
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2735
#ifdef ECONNREFUSED
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2736
	    case ECONNREFUSED:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2737
		sym = @symbol(ECONNREFUSED);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2738
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2739
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2740
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2741
#ifdef ENETDOWN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2742
	    case ENETDOWN:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2743
		sym = @symbol(ENETDOWN);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2744
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2745
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2746
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2747
#ifdef ENETUNREACH
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2748
	    case ENETUNREACH:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2749
		sym = @symbol(ENETUNREACH);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2750
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2751
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2752
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2753
#ifdef ENETRESET
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2754
	    case ENETRESET:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2755
		sym = @symbol(ENETRESET);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2756
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2757
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2758
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2759
#ifdef ECONNABORTED
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2760
	    case ECONNABORTED:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2761
		sym = @symbol(ECONNABORTED);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2762
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2763
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2764
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2765
#ifdef ECONNRESET
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2766
	    case ECONNRESET:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2767
		sym = @symbol(ECONNRESET);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2768
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2769
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2770
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2771
#ifdef EISCONN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2772
	    case EISCONN:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2773
		sym = @symbol(EISCONN);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2774
		typ = @symbol(unpreparedOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2775
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2776
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2777
#ifdef ENOTCONN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2778
	    case ENOTCONN:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2779
		sym = @symbol(ENOTCONN);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2780
		typ = @symbol(unpreparedOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2781
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2782
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2783
#ifdef ESHUTDOWN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2784
	    case ESHUTDOWN:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2785
		sym = @symbol(ESHUTDOWN);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2786
		typ = @symbol(unpreparedOperationSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2787
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2788
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2789
#ifdef EHOSTDOWN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2790
	    case EHOSTDOWN:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2791
		sym = @symbol(EHOSTDOWN);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2792
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2793
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2794
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2795
#ifdef EHOSTUNREACH
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2796
	    case EHOSTUNREACH:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2797
		sym = @symbol(EHOSTUNREACH);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2798
		typ = @symbol(peerFaultSignal);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2799
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2800
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2801
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2802
	    default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2803
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2804
	}
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2805
    }
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2806
%}.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2807
    holder := OSErrorHolder new.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2808
    holder errorSymbol:sym errorCategory:typ.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2809
    ^ holder
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2810
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2811
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2812
     OperatingSystem errorHolderForNumber:4           
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2813
     self errorHolderForNumber:(self errorNumberFor:#EPERM)   
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2814
     self errorHolderForNumber:(self errorNumberFor:#EIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2815
     self errorHolderForNumber:(self errorNumberFor:#ENXIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2816
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2817
!
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2818
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2819
errorNumberFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2820
    "given a symbolic error, return the numeric;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2821
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
     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
  2823
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
%{   /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2825
    OBJ sym = aSymbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2826
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2827
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2828
     * POSIX errnos - these should be defined
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2829
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2830
#ifdef EPERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2831
    if (sym == @symbol(EPERM)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2832
	RETURN ( __MKSMALLINT(EPERM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2833
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2834
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2835
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2836
#ifdef ENOENT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2837
    if (sym == @symbol(ENOENT)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2838
	RETURN ( __MKSMALLINT(ENOENT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2839
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2840
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2841
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2842
#ifdef ESRCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2843
    if (sym == @symbol(ESRCH)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2844
	RETURN ( __MKSMALLINT(ESRCH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2845
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
#ifdef EINTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2849
    if (sym == @symbol(EINTR)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2850
	RETURN ( __MKSMALLINT(EINTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2851
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2852
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2853
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2854
#ifdef EIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2855
    if (sym == @symbol(EIO)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2856
	RETURN ( __MKSMALLINT(EIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2858
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2859
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
#ifdef ENXIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2861
    if (sym == @symbol(ENXIO)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2862
	RETURN ( __MKSMALLINT(ENXIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2863
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2866
#ifdef E2BIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2867
    if (sym == @symbol(E2BIG)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2868
	RETURN ( __MKSMALLINT(E2BIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2869
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2870
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2871
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2872
#ifdef ENOEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2873
    if (sym == @symbol(ENOEXEC)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2874
	RETURN ( __MKSMALLINT(ENOEXEC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2875
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2876
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2877
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2878
#ifdef EBADF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2879
    if (sym == @symbol(EBADF)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2880
	RETURN ( __MKSMALLINT(EBADF) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2881
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2882
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2883
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2884
#ifdef ECHILD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2885
    if (sym == @symbol(ECHILD)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2886
	RETURN ( __MKSMALLINT(ECHILD) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2887
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2888
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2889
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2890
#if defined(EAGAIN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2891
    if (sym == @symbol(EAGAIN)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2892
	RETURN ( __MKSMALLINT(EAGAIN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2893
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2894
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2895
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2896
#ifdef ENOMEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2897
    if (sym == @symbol(ENOMEM)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2898
	RETURN ( __MKSMALLINT(ENOMEM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2899
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2900
#endif
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
#ifdef EACCES
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2903
    if (sym == @symbol(EACCES)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2904
	RETURN ( __MKSMALLINT(EACCES) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2905
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2906
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2907
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2908
#ifdef EFAULT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2909
    if (sym == @symbol(EFAULT)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2910
	RETURN ( __MKSMALLINT(EFAULT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2911
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2912
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2913
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2914
#ifdef EBUSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2915
    if (sym == @symbol(EBUSY)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2916
	RETURN ( __MKSMALLINT(EBUSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2917
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2918
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2919
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2920
#ifdef EXDEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2921
    if (sym == @symbol(EXDEV)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2922
	RETURN ( __MKSMALLINT(EXDEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2923
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2924
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2925
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2926
#ifdef ENODEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2927
    if (sym == @symbol(ENODEV)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2928
	RETURN ( __MKSMALLINT(ENODEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2929
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2930
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2931
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2932
#ifdef ENOTDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2933
    if (sym == @symbol(ENOTDIR)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2934
	RETURN ( __MKSMALLINT(ENOTDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2935
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2936
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2937
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2938
#ifdef EISDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2939
    if (sym == @symbol(EISDIR)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2940
	RETURN ( __MKSMALLINT(EISDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2941
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2942
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2943
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2944
#ifdef EINVAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2945
    if (sym == @symbol(EINVAL)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2946
	RETURN ( __MKSMALLINT(EINVAL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2947
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2948
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2949
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2950
#ifdef ENFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2951
    if (sym == @symbol(ENFILE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2952
	RETURN ( __MKSMALLINT(ENFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2953
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2954
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2955
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2956
#ifdef EMFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2957
    if (sym == @symbol(EMFILE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2958
	RETURN ( __MKSMALLINT(EMFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2959
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2960
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2961
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2962
#ifdef ENOTTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2963
    if (sym == @symbol(ENOTTY)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2964
	RETURN ( __MKSMALLINT(ENOTTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2965
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2966
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2967
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2968
#ifdef EFBIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2969
    if (sym == @symbol(EFBIG)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2970
	RETURN ( __MKSMALLINT(EFBIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2971
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2972
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2973
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2974
#ifdef ENOSPC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2975
    if (sym == @symbol(ENOSPC)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2976
	RETURN ( __MKSMALLINT(ENOSPC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2977
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2978
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2979
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2980
#ifdef ESPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2981
    if (sym == @symbol(ESPIPE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2982
	RETURN ( __MKSMALLINT(ESPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2983
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2984
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2985
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2986
#ifdef EROFS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2987
    if (sym == @symbol(EROFS)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2988
	RETURN ( __MKSMALLINT(EROFS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2989
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2990
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2991
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2992
#ifdef EMLINK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2993
    if (sym == @symbol(EMLINK)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  2994
	RETURN ( __MKSMALLINT(EMLINK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2995
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2996
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2997
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2998
#ifdef EPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2999
    if (sym == @symbol(EPIPE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3000
	RETURN ( __MKSMALLINT(EPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3001
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3002
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3003
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3004
#ifdef EDOM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3005
    if (sym == @symbol(EDOM)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3006
	RETURN ( __MKSMALLINT(EDOM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3007
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3008
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3009
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3010
#ifdef ERANGE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3011
    if (sym == @symbol(ERANGE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3012
	RETURN ( __MKSMALLINT(ERANGE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3013
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3014
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3015
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3016
#ifdef EDEADLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3017
    if (sym == @symbol(EDEADLK)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3018
	RETURN ( __MKSMALLINT(EDEADLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3019
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3020
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3021
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3022
#ifdef ENAMETOOLONG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3023
    if (sym == @symbol(ENAMETOOLONG)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3024
	RETURN ( __MKSMALLINT(ENAMETOOLONG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3025
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3026
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3027
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3028
#ifdef ENOLCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3029
    if (sym == @symbol(ENOLCK)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3030
	RETURN ( __MKSMALLINT(ENOLCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3031
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3032
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3033
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3034
#ifdef ENOSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3035
    if (sym == @symbol(ENOSYS)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3036
	RETURN ( __MKSMALLINT(ENOSYS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3037
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3038
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3039
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3040
#ifdef ENOTEMPTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3041
    if (sym == @symbol(ENOTEMPTY)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3042
	RETURN ( __MKSMALLINT(ENOTEMPTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3043
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3044
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3045
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3046
#ifdef EEXIST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3047
    if (sym == @symbol(EEXIST)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3048
	RETURN ( __MKSMALLINT(EEXIST) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3049
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3050
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3051
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3052
#ifdef EILSEQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3053
    if (sym == @symbol(EILSEQ)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3054
	RETURN ( __MKSMALLINT(EILSEQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3055
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3056
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3057
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3058
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3059
     * XPG3 errnos - defined on most systems
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3060
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3061
#ifdef ENOTBLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3062
    if (sym == @symbol(ENOTBLK)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3063
	RETURN ( __MKSMALLINT(ENOTBLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3064
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3065
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3067
#ifdef ETXTBSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3068
    if (sym == @symbol(ETXTBSY)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3069
	RETURN ( __MKSMALLINT(ETXTBSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3070
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3071
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3072
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3073
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3074
     * some others
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3075
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3076
#ifdef EWOULDBLOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3077
    if (sym == @symbol(EWOULDBLOCK)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3078
	RETURN ( __MKSMALLINT(EWOULDBLOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3079
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3080
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3081
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3082
#ifdef ENOMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3083
    if (sym == @symbol(ENOMSG)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3084
	RETURN ( __MKSMALLINT(ENOMSG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3085
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3086
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3087
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3088
#ifdef ELOOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3089
    if (sym == @symbol(ELOOP)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3090
	RETURN ( __MKSMALLINT(ELOOP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3091
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3092
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3093
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3094
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3095
     * some stream errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3096
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3097
#ifdef ETIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3098
    if (sym == @symbol(ETIME)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3099
	RETURN ( __MKSMALLINT(ETIME) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3101
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3102
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3103
#ifdef ENOSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3104
    if (sym == @symbol(ENOSR)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3105
	RETURN ( __MKSMALLINT(ENOSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3106
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3107
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3108
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3109
#ifdef ENOSTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3110
    if (sym == @symbol(ENOSTR)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3111
	RETURN ( __MKSMALLINT(ENOSTR) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3115
#ifdef ECOMM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3116
    if (sym == @symbol(ECOMM)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3117
	RETURN ( __MKSMALLINT(ECOMM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3118
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3119
#endif
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
#ifdef EPROTO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3122
    if (sym == @symbol(EPROTO)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3123
	RETURN ( __MKSMALLINT(EPROTO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3124
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3125
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3126
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3127
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3128
     * nfs errors
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
#ifdef ESTALE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3131
    if (sym == @symbol(ESTALE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3132
	RETURN ( __MKSMALLINT(ESTALE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3133
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3134
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3135
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3136
#ifdef EREMOTE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3137
    if (sym == @symbol(EREMOTE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3138
	RETURN ( __MKSMALLINT(EREMOTE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3139
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3140
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
     * some networking errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
#ifdef EINPROGRESS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
    if (sym == @symbol(EINPROGRESS)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3147
	RETURN ( __MKSMALLINT(EINPROGRESS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
#ifdef EALREADY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3152
    if (sym == @symbol(EALREADY)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3153
	RETURN ( __MKSMALLINT(EALREADY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3155
#endif
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
#ifdef ENOTSOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3158
    if (sym == @symbol(ENOTSOCK)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3159
	RETURN ( __MKSMALLINT(ENOTSOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
#endif
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
#ifdef EDESTADDRREQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
    if (sym == @symbol(EDESTADDRREQ)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3165
	RETURN ( __MKSMALLINT(EDESTADDRREQ) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3168
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3169
#ifdef EMSGSIZE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3170
    if (sym == @symbol(EMSGSIZE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3171
	RETURN ( __MKSMALLINT(EMSGSIZE) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3174
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3175
#ifdef EPROTOTYPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3176
    if (sym == @symbol(EPROTOTYPE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3177
	RETURN ( __MKSMALLINT(EPROTOTYPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3178
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3179
#endif
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
#ifdef ENOPROTOOPT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3182
    if (sym == @symbol(ENOPROTOOPT)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3183
	RETURN ( __MKSMALLINT(ENOPROTOOPT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3184
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3185
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3186
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3187
#ifdef EPROTONOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3188
    if (sym == @symbol(EPROTONOSUPPORT)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3189
	RETURN ( __MKSMALLINT(EPROTONOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3190
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3191
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3192
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3193
#ifdef ESOCKTNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3194
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3195
	RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3196
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3197
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3198
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3199
#ifdef EOPNOTSUPP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3200
    if (sym == @symbol(EOPNOTSUPP)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3201
	RETURN ( __MKSMALLINT(EOPNOTSUPP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3202
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3203
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3204
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3205
#ifdef EPFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3206
    if (sym == @symbol(EPFNOSUPPORT)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3207
	RETURN ( __MKSMALLINT(EPFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3208
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3209
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3210
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3211
#ifdef EAFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3212
    if (sym == @symbol(EAFNOSUPPORT)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3213
	RETURN ( __MKSMALLINT(EAFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3214
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3215
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3216
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3217
#ifdef EADDRINUSE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3218
    if (sym == @symbol(EADDRINUSE)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3219
	RETURN ( __MKSMALLINT(EADDRINUSE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3220
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3221
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3222
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3223
#ifdef EADDRNOTAVAIL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3224
    if (sym == @symbol(EADDRNOTAVAIL)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3225
	RETURN ( __MKSMALLINT(EADDRNOTAVAIL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3226
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3227
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3228
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3229
#ifdef ETIMEDOUT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3230
    if (sym == @symbol(ETIMEDOUT)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3231
	RETURN ( __MKSMALLINT(ETIMEDOUT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3232
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3233
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3234
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3235
#ifdef ECONNREFUSED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3236
    if (sym == @symbol(ECONNREFUSED)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3237
	RETURN ( __MKSMALLINT(ECONNREFUSED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3238
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3239
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3240
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3241
#ifdef ENETDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3242
    if (sym == @symbol(ENETDOWN)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3243
	RETURN ( __MKSMALLINT(ENETDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3244
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3245
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3246
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3247
#ifdef ENETUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3248
    if (sym == @symbol(ENETUNREACH)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3249
	RETURN ( __MKSMALLINT(ENETUNREACH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3250
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3251
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3252
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3253
#ifdef ENETRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3254
    if (sym == @symbol(ENETRESET)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3255
	RETURN ( __MKSMALLINT(ENETRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3256
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3257
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3258
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3259
#ifdef ECONNABORTED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3260
    if (sym == @symbol(ECONNABORTED)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3261
	RETURN ( __MKSMALLINT(ECONNABORTED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3262
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3263
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3264
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3265
#ifdef ECONNRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3266
    if (sym == @symbol(ECONNRESET)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3267
	RETURN ( __MKSMALLINT(ECONNRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3268
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3269
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3270
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3271
#ifdef EISCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3272
    if (sym == @symbol(EISCONN)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3273
	RETURN ( __MKSMALLINT(EISCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3274
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3275
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3276
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3277
#ifdef ENOTCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3278
    if (sym == @symbol(ENOTCONN)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3279
	RETURN ( __MKSMALLINT(ENOTCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3280
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3281
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3282
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3283
#ifdef ESHUTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3284
    if (sym == @symbol(ESHUTDOWN)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3285
	RETURN ( __MKSMALLINT(ESHUTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3286
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3287
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3288
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3289
#ifdef EHOSTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3290
    if (sym == @symbol(EHOSTDOWN)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3291
	RETURN ( __MKSMALLINT(EHOSTDOWN) );
3496
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
#endif
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
#ifdef EHOSTUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3296
    if (sym == @symbol(EHOSTUNREACH)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3297
	RETURN ( __MKSMALLINT(EHOSTUNREACH) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3298
    }
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3299
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3300
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3301
    ^ -1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3302
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3303
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3304
!UnixOperatingSystem class methodsFor:'executing OS commands'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3305
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3306
commandAndArgsForOSCommand:aCommandString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3307
    "get a shell and shell arguments for command execution"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3308
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3309
    |shell args|
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3310
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3311
    "/
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3312
    "/ '/bin/sh -c <command>'
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3313
    "/
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3314
    shell := '/bin/sh'.
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3315
    args := Array with:'sh' with:'-c' with:aCommandString.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3316
    ^ Array with:shell with:args
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3317
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3318
    "Modified: / 20.1.1998 / 16:57:19 / md"
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3319
    "Modified: / 5.6.1998 / 17:40:48 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3320
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3321
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3322
exec:aCommandPath withArguments:argColl environment:env fileDescriptors:fdColl closeDescriptors:closeFdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3323
    "Internal lowLevel entry for combined fork & exec;
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3324
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3325
     If fork is false (chain a command):
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3326
	 execute the OS command specified by the argument, aCommandPath, with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3327
	 arguments in argArray (no arguments, if nil).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3328
	 If successful, this method does not return and smalltalk is gone.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3329
	 If not successful, it does return.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3330
	 Normal use is with forkForCommand.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3331
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3332
     If fork is true (subprocess command execution):
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3333
	fork a child to do the above.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3334
	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
  3335
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3336
     fdArray contains the filedescriptors, to be used for the child (if fork is true).
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3337
	fdArray[1] = 15 -> use fd 15 as stdin.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3338
	If an element of the array is set to nil, the corresponding filedescriptor
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3339
	will be closed for the child.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3340
	fdArray[0] == StdIn for child
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3341
	fdArray[1] == StdOut for child
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3342
	fdArray[2] == StdErr for child
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3343
	on VMS, these must be channels as returned by createMailBox.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3344
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3345
     closeFdArray contains descriptors that will be closed in the subprocess.
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3346
	closeDescriptors are ignored in the WIN32 & VMS versions.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3347
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3348
     If newPgrp is true, the subprocess will be established in a new process group.
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3349
	The processgroup will be equal to id.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3350
	newPgrp is not used on WIN32 and VMS systems.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3351
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3352
     env specifies environment variables which are passed differently from
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3353
     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
  3354
     key-value pairs for changed/added environment variables.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3355
     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
  3356
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3357
     Notice: this used to be two separate ST-methods; however, in order to use
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3358
	    vfork on some machines, it had to be merged into one, to avoid write
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3359
	    accesses to ST/X memory from the vforked-child.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3360
	    The code below only does read accesses."
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3361
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3362
    |envPairs argArray fdArray closeFdArray dirName|
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3363
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3364
    env notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3365
	envPairs := OrderedCollection new.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3366
	env keysAndValuesDo:[:key :val |
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3367
	    envPairs add:key; add:val
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3368
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3369
	envPairs := envPairs asArray.
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3370
    ].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3371
    argColl notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3372
	argArray := argColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3373
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3374
    fdColl notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3375
	fdArray := fdColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3376
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3377
    closeFdColl notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3378
	closeFdArray := closeFdColl asArray
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3379
    ].
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  3380
    aDirectory notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3381
	dirName := aDirectory asFilename name
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  3382
    ].
3496
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
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3385
    char **argv;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3386
    int nargs, i, id;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3387
    OBJ arg;
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3388
    extern char **environ;
3571
9090dc66a427 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
  3389
    char **_env, **_nEnv;
3801
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  3390
#ifndef __isArrayLike
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  3391
# define __isArrayLike __isArray
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  3392
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3393
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3394
    if (__isString(aCommandPath) && 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3395
	((argArray == nil) || __isArrayLike(argArray)) &&
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3396
	((fdArray == nil) || __isArrayLike(fdArray)) &&
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3397
	((closeFdArray == nil) || __isArrayLike(closeFdArray))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3398
    ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3399
	nargs = argArray == nil ? 0 : __arraySize(argArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3400
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3401
	if (argv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3402
	    int nOldEnv, nNewEnv;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3403
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3404
	    for (i=0; i < nargs; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3405
		arg = __ArrayInstPtr(argArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3406
		if (__isString(arg)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3407
		    argv[i] = (char *) __stringVal(arg);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3408
		} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3409
		    argv[i] = "";
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3410
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3411
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3412
	    argv[i] = NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3413
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3414
	    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3415
	     * number of new items in environment ..       
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3416
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3417
	    nNewEnv = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3418
	    if ((envPairs != nil) && __isArrayLike(envPairs)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3419
		nNewEnv = __arraySize(envPairs) / 2;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3420
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3421
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3422
	    if (nNewEnv == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3423
		_nEnv = environ;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3424
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3425
		_env = environ;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3426
		/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3427
		 * get size of environment
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3428
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3429
		nOldEnv = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3430
		if (_env) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3431
		    while (*_env) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3432
			nOldEnv++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3433
			_env++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3434
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3435
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3436
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3437
		/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3438
		 * generate a new environment
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3439
		 * I have not found a spec which defines if
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3440
		 * items at the end overwrite previous definitions,
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3441
		 * or if the first encountered definition is valid.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3442
		 * To be prepared for any case, simply add the new definitions
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3443
		 * at both ends - that should do it in any case.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3444
		 * Someone with more know-how may want to fix this.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3445
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3446
		_nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3447
		if (_nEnv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3448
		    char **eO, **eN;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3449
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3450
		    eN = _nEnv;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3451
		    if (nNewEnv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3452
			/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3453
			 * add new items at the front ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3454
			 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3455
			int i;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3456
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3457
			for (i=0; (i+1)<__arraySize(envPairs); i+=2) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3458
			    OBJ t;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3459
			    char *var, *val, *e;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3460
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3461
			    t = __ArrayInstPtr(envPairs)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3462
			    if (__isString(t) || __isSymbol(t)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3463
				var = (char *)__stringVal(t);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3464
				t = __ArrayInstPtr(envPairs)->a_element[i+1];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3465
				if (__isString(t) || __isSymbol(t)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3466
				    val = (char *)__stringVal(t);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3467
				} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3468
				    val = NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3469
				}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3470
				if (val != NULL) {                
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3471
				    e = (char *)malloc(strlen(var) + 1 + strlen(val) + 1);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3472
				    strcpy(e, var);               
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3473
				    strcat(e, "=");               
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3474
				    strcat(e, val);               
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3475
				} else {                          
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3476
				    e = (char *)malloc(strlen(var) + 1 + 1);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3477
				    strcpy(e, var);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3478
				    strcat(e, "=");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3479
				}   
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3480
				*eN++ = e;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3481
			    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3482
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3483
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3484
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3485
		    if (nOldEnv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3486
			/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3487
			 * append old environment 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3488
			 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3489
			eO = environ;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3490
			while (*eN = *eO++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3491
			    eN++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3492
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3493
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3494
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3495
		    if (nNewEnv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3496
			/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3497
			 * new items again at the end
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3498
			 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3499
			for (eO = _nEnv, i=0; i<nNewEnv; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3500
			    *eN++ = *eO++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3501
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3502
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3503
			*eN = NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3504
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3505
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3506
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3507
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3508
	    if (doFork == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3509
		/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3510
		 * fork a subprocess.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3511
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3512
		int nfd, nclose;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3513
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3514
		nfd = fdArray == nil ? 0 : __arraySize(fdArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3515
		nclose = closeFdArray == nil ? 0 : __arraySize(closeFdArray);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3516
#ifdef HAS_VFORK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3517
		id = vfork();
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3518
#else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3519
		id = fork();
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3520
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3521
		if (id == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3522
		    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3523
		    ** In child.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3524
		    ** first: dup filedescriptors
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3525
		    */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3526
		    for (i = 0; i < nfd; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3527
			OBJ fd;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3528
			int rslt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3529
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3530
			fd = __ArrayInstPtr(fdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3531
			if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3532
			    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3533
				rslt = dup2(__intVal(fd), i);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3534
			    } while ((rslt < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3535
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3536
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3537
		    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3538
		    ** second: close unused filedescriptors
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3539
		    */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3540
		    for (i = 0; i < nfd; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3541
			if (__ArrayInstPtr(fdArray)->a_element[i] == nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3542
			    close(i);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3543
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3544
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3545
		    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3546
		    ** third: close filedescriptors
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3547
		    */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3548
		    for (i = 0; i < nclose; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3549
			OBJ fd;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3550
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3551
			fd = __ArrayInstPtr(closeFdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3552
			if (__isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3553
			    close(__intVal(fd));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3554
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3555
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3556
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3557
		    if (newPgrp == true) {
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3558
#ifndef NEXT
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3559
			setsid();
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3560
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3561
#if defined(TIOCSCTTY)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3562
			ioctl(0, TIOCSCTTY, 0) ;
3561
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3563
#endif
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3564
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3565
#if defined(TIOCSPGRP)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3566
			{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3567
			    int pgrp = getpid();
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3568
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3569
			    ioctl(0, TIOCSPGRP, (char *)&pgrp);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3570
			}
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3571
#endif
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3572
#if defined(_POSIX_JOB_CONTROL)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3573
			(void) setpgid(0, 0);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3574
#else
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3575
# if defined(BSD) || defined(LINUX)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3576
			(void) setpgrp(0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3577
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3578
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3579
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3580
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3581
		    if (dirName != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3582
			chdir(__stringVal(dirName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3583
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3584
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3585
		    execve(__stringVal(aCommandPath), argv, _nEnv);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3586
		    /* should not be reached */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3587
		    _exit(127);                 /* POSIX 2 compatible exit value */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3588
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3589
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3590
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3591
		if (dirName != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3592
		    chdir(__stringVal(dirName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3593
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3594
		/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3595
		 * no subprocess (i.e. transfer to another program)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3596
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3597
		execve(__stringVal(aCommandPath), argv, _nEnv);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3598
		/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3599
		 * should not be reached
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3600
		 * (well, it is, if you pass a wrong command-path)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3601
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3602
		id = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3603
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3604
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3605
	    if (nNewEnv && (_nEnv != NULL)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3606
		/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3607
		 * free new environment stuff
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3608
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3609
		for (i=0; i<nNewEnv;i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3610
		    char *e = _nEnv[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3611
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3612
		    if (e) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3613
			free(e);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3614
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3615
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3616
		free(_nEnv);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3617
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3618
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3619
	    free(argv);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3620
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3621
	    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3622
	     * In parent: succes or failure
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3623
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3624
	    if (id == -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3625
		RETURN (nil);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3626
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3627
		RETURN (__MKSMALLINT(id));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3628
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3629
	}
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3630
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3631
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3632
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3633
     path-argument not string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3634
     or argArray not an array/nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3635
     or malloc failed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3636
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3637
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3638
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3639
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3640
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3641
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3642
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3643
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3644
     id == 0 ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3645
	'I am the child'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3646
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3647
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3648
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3649
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3650
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3651
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3652
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3653
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3654
     id == 0 ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3655
	'I am the child'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3656
	OperatingSystem
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3657
	   exec:'/bin/sh'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3658
	   withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3659
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3660
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3661
     id printNL.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3662
     (Delay forSeconds:3.5) wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3663
     'killing ...' printNL.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3664
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3665
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3666
    "
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3667
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3668
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3670
executeCommand:aCommandString inDirectory:aDirectory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3671
    "much like #executeCommand:, but changes the current directory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3672
     for the command. Since this is OS specific, use this instead of
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3673
     hardwiring any 'cd ..' command strings into your applictions."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3674
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3675
     ^ self
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3676
	executeCommand:aCommandString 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3677
	inputFrom:nil 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3678
	outputTo:nil 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3679
	errorTo:nil 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3680
	inDirectory:aDirectory asFilename name
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3681
	onError:[:status| false].
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3682
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3683
"/    | cmd |
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3684
"/
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3685
"/    "/ unix - prepend a 'cd' to the command
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3686
"/
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3687
"/    cmd := 'cd ' , aDirectory asFilename name, '; ' , aCommandString.
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3688
"/    ^ self executeCommand:cmd
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3689
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3690
    "Modified: / 20.1.1998 / 17:03:03 / md"
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3691
    "Modified: / 5.6.1998 / 19:01:29 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3692
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3693
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3694
fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3695
    "fork a new (HEAVY-weight) unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3696
     Not supported with MSDOS & VMS systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3697
     Dont confuse this with Block>>fork, which creates 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3698
     lightweight smalltalk processes. This method will return
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3699
     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
  3700
     unix-process-id) to the parent (original) process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3701
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3702
     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
  3703
     #startProcess: and #executCommand: for higher level interfaces."
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3706
    int pid;
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
    pid = fork();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3709
    RETURN ( __MKUINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3710
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3711
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3712
    "/ not supported by OS
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
    ^ UnsupportedOperationSignal raise
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3718
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3719
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3720
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3721
     id == 0 ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3722
	'I am the child process' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3723
	OperatingSystem exit
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3724
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3725
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3726
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3728
getStatusOfProcess:aProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3729
    "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
  3730
     This is required to avoid zombie processes."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3731
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3732
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3733
    int status;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3734
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3735
    if (__isSmallInteger(aProcessId)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3736
	pid_t pid = (pid_t)(__intVal(aProcessId));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3737
	{
3496
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
# ifdef  NO_WAITPID
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3740
	    pid_t child;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3741
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3742
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3743
		__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3744
		child = __wait (&status);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3745
		__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3746
		if (child < 0 && errno != EINTR) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3747
		    fprintf(stderr, "OS: child-wait errno=%d\n", errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3748
		    status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3749
		    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3750
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3751
	    } while (child != pid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3752
# else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3753
	    pid_t child;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3754
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3755
	    /* claus: the original did not care for EINTR here ... */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3756
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3757
		__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3758
		child = __waitpid (pid, &status, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3759
		__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3760
	    } while ((child != pid) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3761
	    if (child != pid) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3762
		fprintf(stderr, "OS: child-waitpid errno=%d\n", errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3763
		status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3764
	    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3765
# endif /* NO_WAITPID */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3766
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3767
	RETURN ( __MKSMALLINT(status));
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3768
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3769
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3770
    self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3771
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3772
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3773
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3774
pathOfCommand:aCommand
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3775
    "find where aCommand's executable file is;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3776
     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
  3777
     return nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3778
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3779
    |path f fExt|
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
    aCommand asFilename isAbsolute ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3782
	^ aCommand
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3783
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3784
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3785
    path := self getEnvironment:'PATH'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3786
    path notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3787
	(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3788
	    path isEmpty ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3789
		f := aCommand asFilename
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3790
	    ] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3791
		f := path asFilename construct:aCommand.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3792
	    ].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3793
	    self executableFileExtensions do:[:ext |
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3794
		ext notEmpty ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3795
		    fExt := (f pathName , ext) asFilename.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3796
		] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3797
		    fExt := f.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3798
		].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3799
		fExt isExecutable ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3800
		    ^ fExt pathName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3801
		].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3802
	    ].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3803
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3804
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3805
    ^ nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3806
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3807
    "unix:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3808
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3809
     OperatingSystem pathOfCommand:'fooBar'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3810
     OperatingSystem pathOfCommand:'ls'    
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3811
     OperatingSystem pathOfCommand:'cvs'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3812
     OperatingSystem pathOfCommand:'stx'   
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3813
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3814
    "windows:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3815
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3816
     OperatingSystem pathOfCommand:'windbg'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3817
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3818
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3819
    "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
  3820
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3821
3928
c299502a62b9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  3822
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream inDirectory:dir
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3823
    "start executing the OS command as specified by the argument, aCommandString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3824
     as a separate process; do not wait for the command to finish.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3825
     The commandString is passed to a shell for execution - see the description of
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3826
     'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3827
     The command gets stdIn, stdOut and stdErr assigned from the arguments;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3828
     each may be nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3829
     Return the processId if successful, nil otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3830
     Use #monitorPid:action: for synchronization and exec status return,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3831
     or #killProcess: to stop it."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3832
6617
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3833
    |nullStream in out err shellAndArgs rslt|
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3834
4753
214fc4e89e7a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4436
diff changeset
  3835
    aCommandString isNil ifTrue:[^ nil].
214fc4e89e7a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4436
diff changeset
  3836
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3837
    (in := anExternalInStream) isNil ifTrue:[
6617
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3838
        nullStream := Filename nullDevice readWriteStream.
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3839
        in := nullStream. 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3840
    ].
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3841
    (out := anExternalOutStream) isNil ifTrue:[
6617
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3842
        nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3843
        out := nullStream.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3844
    ].
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3845
    (err := anExternalErrStream) isNil ifTrue:[
6617
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3846
        err := out
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3847
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3848
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3849
    shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
4753
214fc4e89e7a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4436
diff changeset
  3850
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3851
    rslt := self
6617
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3852
        exec:(shellAndArgs at:1)
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3853
        withArguments:(shellAndArgs at:2)
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3854
        fileDescriptors:(Array with:in fileDescriptor
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3855
                               with:out fileDescriptor
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3856
                               with:err fileDescriptor)
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3857
        closeDescriptors:nil
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3858
        fork:true
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3859
        newPgrp:true "/ false
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3860
        inDirectory:dir.
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3861
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3862
    nullStream notNil ifTrue:[
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3863
        nullStream close.
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3864
    ].
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3865
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3866
    ^ rslt
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
    "blocking at current prio (i.e. only higher prio threads execute):
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3869
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3870
     OperatingSystem executeCommand:'ls -l > out'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3871
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3872
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3873
    "non-blocking (lower prio threads continue):
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3874
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3875
     |in out err pid sema|
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
     in := 'out' asFilename readStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3878
     out := 'out2' asFilename writeStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3879
     err := 'err' asFilename writeStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3880
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3881
     sema := Semaphore new.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3882
     pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3883
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3884
     The following will no longer work. monitorPid has disappeared 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3885
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3886
     pid notNil ifTrue:[
6617
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
  3887
         Processor monitorPid:pid action:[:OSstatus | sema signal ].
3496
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
     in close.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3890
     out close.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3891
     err close.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3892
     sema wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3893
     Transcript showCR:'finished'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3894
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3895
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3896
    "Modified: / 21.3.1997 / 10:04:35 / dq"
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3897
    "Modified: / 15.7.1997 / 16:03:51 / stefan"
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3898
    "Modified: / 5.6.1998 / 19:03:51 / cg"
3928
c299502a62b9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  3899
    "Created: / 12.11.1998 / 14:39:20 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3900
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3901
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3902
!UnixOperatingSystem class methodsFor:'file access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3903
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3904
closeFd:anInteger
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3905
    "low level close of a filedescriptor"
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
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3908
     if (__isSmallInteger(anInteger)) {
5203
a1a9869b2d24 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5157
diff changeset
  3909
	if (@global(ExternalStream:FileOpenTrace) == true) {
a1a9869b2d24 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5157
diff changeset
  3910
	    fprintf(stderr, "close [UnixOp] fd=%d\n", __intVal(anInteger));
a1a9869b2d24 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5157
diff changeset
  3911
	}
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3912
	close(__intVal(anInteger));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3913
	RETURN(self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3914
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3915
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3916
     ^ self primitiveFailed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3917
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3918
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3919
createDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3920
    "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
  3921
     path, or relative to the current directory.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3922
     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
  3923
     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
  3924
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3925
    "/ if it already exists this is ok
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 isDirectory:aPathName) ifTrue:[^ true].
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
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3930
    if (__isString(aPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3931
	int ret;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3932
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3933
	ret = mkdir(__stringVal(aPathName), 0755);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3934
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3935
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3936
	    RETURN (false);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3937
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3938
	RETURN (true);
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3942
"/    self isUNIXlike ifTrue:[
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3943
"/      ^ self executeCommand:('mkdir 2>/dev/null ', newPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3944
"/    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3945
"/    ^ self executeCommand:('mkdir ', newPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3946
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3947
    self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3948
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3949
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3950
     OperatingSystem createDirectory:'foo'  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3951
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3952
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3953
    "Modified: 20.12.1995 / 11:24:13 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3954
    "Modified: 29.6.1996 / 14:06:54 / cg"
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
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3957
createFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3958
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3959
    ^ 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
  3960
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3961
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3962
createFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3963
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3964
    ^ 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
  3965
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3966
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3967
createHardLinkFrom:oldPath to:newPath
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3968
    "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
  3969
     Return true if successful, false if not."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3970
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
    int ret;
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
    if (__isString(oldPath) && __isString(newPath)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3975
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3976
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3977
	    ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3978
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3979
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3980
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3981
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3982
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3983
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3984
	RETURN (true);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3985
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3986
%}.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3987
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3988
    "/ bad argument(s) given
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3989
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3990
    ^ self primitiveFailed 
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3991
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3992
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3993
     OperatingSystem linkFile:'foo' to:'bar'
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3994
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3995
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3996
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3997
createSymbolicLinkFrom:oldPath to:newPath
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3998
    "make a symbolic link for 'newPath' to the file 'oldPath'.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3999
     The link will be a soft (symbolic) link.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4000
     Return true if successful, false if not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4001
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4002
%{
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4003
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4004
    int ret;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4005
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4006
    if (__isString(oldPath) && __isString(newPath)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4007
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4008
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4009
	    ret = symlink((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4010
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4011
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4012
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4013
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4014
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4015
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4016
	RETURN (true);
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4017
    }
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4018
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4019
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4020
    (oldPath isString not or:[newPath isString not]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4021
	"/
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4022
	"/ bad argument(s) given
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4023
	"/
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4024
	^ self primitiveFailed 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4025
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4026
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4027
    "/
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  4028
    "/ 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
  4029
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4030
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4031
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4032
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4033
     OperatingSystem symbolicLinkFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4034
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4035
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4036
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4037
open:path attributes:attributes mode:modeInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4038
    "open a file, return an os specific fileHandle. 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4039
     openmode is a symbol defining the way to open
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4040
     valid modes are:
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4041
	#O_RDONLY
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4042
	#O_RDWR
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4043
	#O_WRONLY
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4044
	#O_CREAT
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4045
	#O_APPEND
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4046
	#O_SYNC
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4047
	#O_LARGEFILE
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4048
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4049
     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
  4050
     which is proprietrary to the operatingSystem."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4051
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4052
    |error fileDescriptor|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4053
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4054
%{
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4055
    OBJ *ap;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4056
    int nAttributes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4057
    int fd;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4058
    int mode, openFlags = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4059
    int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4060
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4061
    if (!__isString(path)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4062
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4063
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4064
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4065
    if (!__isArray(attributes)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4066
	error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4067
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4068
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4069
    if (modeInteger == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4070
	mode = 0644;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4071
    } else if (__isSmallInteger(modeInteger)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4072
	mode = __intVal(modeInteger);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4073
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4074
	error = @symbol(badArgument3);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4075
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4076
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4077
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4078
    nAttributes = __arraySize(attributes);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4079
    for (n = 0, ap = __arrayVal(attributes); n < nAttributes; n++) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4080
	OBJ attribute = ap[n];
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4081
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4082
	if (attribute == @symbol(O_RDONLY)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4083
	    openFlags |= O_RDONLY;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4084
	} else if (attribute == @symbol(O_RDWR)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4085
	    openFlags |= O_RDWR;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4086
	} else if (attribute == @symbol(O_WRONLY)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4087
	    openFlags |= O_WRONLY;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4088
	} else if (attribute == @symbol(O_CREAT)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4089
	    openFlags |= O_CREAT;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4090
	} else if (attribute == @symbol(O_APPEND)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4091
	    openFlags |= O_APPEND;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4092
	} else if (attribute == @symbol(O_EXCL)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4093
	    openFlags |= O_EXCL;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4094
	} else if (attribute == @symbol(O_TRUNC)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4095
	    openFlags |= O_TRUNC;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4096
	} else if (attribute == @symbol(O_LARGEFILE)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4097
#ifdef O_LARGEFILE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4098
	    openFlags |= O_LARGEFILE;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4099
#else
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4100
	    error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4101
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4102
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4103
	} else if (attribute == @symbol(O_SYNC)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4104
#ifdef O_SYNC
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4105
	    openFlags |= O_SYNC;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4106
#else
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4107
	    error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4108
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4109
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4110
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4111
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4112
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4113
#if defined(O_NONBLOCK)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4114
    openFlags |= O_NONBLOCK;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4115
#else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4116
# if defined(O_NDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4117
    openFlags |= O_NDELAY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4118
# endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4119
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4120
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4121
again:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4122
    fd = open((char *) __stringVal(path), openFlags, mode);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4123
    if (fd < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4124
	if (errno == EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4125
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4126
	    goto again;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4127
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4128
	    error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4129
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4130
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4131
    }
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  4132
    fileDescriptor = __mkSmallInteger(fd);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4133
err:;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4134
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4135
    ^ fileDescriptor notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4136
	FileDescriptorHandle for:fileDescriptor.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4137
    ] ifFalse:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4138
	(self errorHolderForNumber:error) reportError
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4139
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4140
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4141
    "
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4142
	self open:'/etc/hosts' attributes:#(O_RDONLY) mode:nil
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4143
	self open:'/tmp/xxzz' attributes:#(O_RDWR O_CREAT) mode:8r611
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4144
	self open:'/etc/passwd' attributes:#(O_RDWR) mode:nil
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4145
	self open:'/no one knows this file' attributes:#(O_RDONLY) mode:nil
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4146
	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
  4147
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4148
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4149
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4150
openFileForAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4151
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4152
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4153
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4154
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4155
openFileForRead:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4156
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4157
    ^ self open:pathName attributes:#(O_RDONLY) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4158
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4159
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4160
openFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4161
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4162
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4163
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4164
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4165
openFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4166
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4167
    ^ self open:pathName attributes:#(O_RDWR)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4168
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4169
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4170
openFileForWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4171
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  4172
    ^ self open:pathName attributes:#(O_WRONLY)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4173
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  4174
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4175
recursiveCopyDirectory:sourcePathName to:destination
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4176
    "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
  4177
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4178
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4179
    ^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination)
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4180
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4181
    "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
  4182
!
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
recursiveRemoveDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4185
    "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
  4186
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4187
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4188
    ^ self executeCommand:('rm -rf ' , fullPathName)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4190
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4191
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4192
     OperatingSystem recursiveRemoveDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4193
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4194
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4195
    "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
  4196
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4197
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4198
removeDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4199
    "remove the directory named 'fullPathName'. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4200
     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
  4201
     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
  4202
     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
  4203
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
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4206
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4207
    if (__isString(fullPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4208
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4209
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4210
	    ret = rmdir((char *) __stringVal(fullPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4211
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4212
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4213
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4214
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4215
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4216
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4217
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4218
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4219
%}.
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
    "/ either not a string argument,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4222
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4223
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4224
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4225
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4226
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4227
     OperatingSystem createDirectory:'foo'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4228
     OperatingSystem removeDirectory:'foo'
3496
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
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4233
removeFile:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4234
    "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
  4235
     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
  4236
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
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4240
    if (__isString(fullPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4241
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4242
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4243
	    ret = unlink((char *) __stringVal(fullPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4244
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4245
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4246
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4247
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4248
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4249
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4250
	RETURN (true);
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
    ^ self primitiveFailed
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
renameFile:oldPath to:newPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4257
    "rename the file 'oldPath' to 'newPath'. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4258
     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
  4259
     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
  4260
     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
  4261
     any invalid names.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4262
     Returns true if successful, false if not"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4263
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4264
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4265
    int ret, eno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4266
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4267
    if (__isString(oldPath) && __isString(newPath)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4268
#if defined(HAS_RENAME)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4269
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4270
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4271
	    ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4272
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4273
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4274
#else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4275
	ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4276
	if (ret >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4277
	    ret = unlink((char *) __stringVal(oldPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4278
	    if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4279
		eno = errno;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4280
		unlink((char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4281
		errno = eno;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4282
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4283
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4284
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4285
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4286
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4287
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4288
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4289
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4290
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4291
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4292
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4293
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4294
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4295
     OperatingSystem renameFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4296
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4297
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4298
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4299
truncateFile:aPathName to:newSize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4300
    "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
  4301
     This may not be supported on all architectures.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4302
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4303
     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
  4304
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4305
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4306
#ifdef HAS_TRUNCATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4307
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4308
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4309
    if (__isString(aPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4310
     && __isSmallInteger(newSize)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4311
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4312
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4313
	    ret = truncate((char *) __stringVal(aPathName), __intVal(newSize));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4314
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4315
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4316
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4317
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4318
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4319
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4320
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4321
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4322
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4323
# ifdef HAS_FTRUNCATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4324
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4325
    int fd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4326
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4327
    if (__isString(aPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4328
     && __isSmallInteger(newSize)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4329
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4330
	    fd = open((char *) __stringVal(aPathName), 2);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4331
	} while (fd < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4332
	if (fd < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4333
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4334
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4335
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4336
        
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4337
	ret = ftruncate(fd, __intVal(newSize));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4338
	close(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4339
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4340
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4341
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4342
	} 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4343
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4344
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4345
# endif /* using FTRUNCATE */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4346
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4347
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4348
    ^ self primitiveFailed
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
!UnixOperatingSystem class methodsFor:'file access rights'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4352
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4353
accessMaskFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4354
    "return the access bits mask for numbers as returned by 
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4355
     OperatingSystem>>accessModeOf:
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4356
     and expected by OperatingSystem>>changeAccessModeOf:to:.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4357
     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
  4358
     (never hardcode 8rxxx into your code)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4359
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4360
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4361
#   ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4362
    /* posix systems should define these ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4363
#    define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4364
#    define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4365
#    define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4366
#    define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4367
#    define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4368
#    define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4369
#    define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4370
#    define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4371
#    define S_IXOTH 0001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4372
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4373
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4374
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4375
    if (aSymbol == @symbol(readUser)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4376
	RETURN ( __MKSMALLINT(S_IRUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4377
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4378
    if (aSymbol == @symbol(writeUser)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4379
	RETURN ( __MKSMALLINT(S_IWUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4380
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4381
    if (aSymbol == @symbol(executeUser)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4382
	RETURN ( __MKSMALLINT(S_IXUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4383
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4384
    if (aSymbol == @symbol(readGroup)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4385
	RETURN ( __MKSMALLINT(S_IRGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4386
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4387
    if (aSymbol == @symbol(writeGroup)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4388
	RETURN ( __MKSMALLINT(S_IWGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4389
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4390
    if (aSymbol == @symbol(executeGroup)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4391
	RETURN ( __MKSMALLINT(S_IXGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4392
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4393
    if (aSymbol == @symbol(readOthers)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4394
	RETURN ( __MKSMALLINT(S_IROTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4395
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4396
    if (aSymbol == @symbol(writeOthers)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4397
	RETURN ( __MKSMALLINT(S_IWOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4398
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4399
    if (aSymbol == @symbol(executeOthers)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4400
	RETURN ( __MKSMALLINT(S_IXOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4401
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4402
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4403
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4404
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4405
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4406
     OperatingSystem accessMaskFor:#readUser
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4407
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4408
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4409
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4410
accessModeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4411
    "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
  4412
     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
  4413
     Notice that the returned number is OS dependent - use the 
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4414
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4415
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4416
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4417
     this could have been implemented as:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4418
	(self infoOf:aPathName) at:#mode
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4419
     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
  4420
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4421
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4422
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4423
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4424
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4425
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4426
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4427
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4428
	printf("stat on '%s' for accessMode\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4429
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4430
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4431
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4432
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4433
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4434
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4435
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4436
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4437
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4438
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4439
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4440
	RETURN ( __MKSMALLINT(buf.st_mode & 0777) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4441
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4442
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4443
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4444
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4445
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4446
    (OperatingSystem accessModeOf:'/') printStringRadix:8
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4447
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4448
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4449
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4450
changeAccessModeOf:aPathName to:modeBits
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4451
    "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
  4452
     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
  4453
     independent. Return true if changed, 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4454
     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
  4455
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4456
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4457
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4458
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4459
    if (__isString(aPathName) && __isSmallInteger(modeBits)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4460
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4461
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4462
	    ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4463
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4464
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4465
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4466
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4467
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4468
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4469
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4470
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4471
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4472
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4473
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4474
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4475
!UnixOperatingSystem class methodsFor:'file locking'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4476
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4477
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4478
   "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
  4479
    (such as returned by ExternalStream>>fileDescriptor).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4480
    On some systems, only advisory locks are available -
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4481
    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
  4482
    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
  4483
    (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
  4484
    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
  4485
    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
  4486
    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
  4487
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4488
    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
  4489
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4490
    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
  4491
    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
  4492
    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
  4493
    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
  4494
    argument."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4495
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4496
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4497
    if (__isSmallInteger(aFileDescriptor)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4498
	int fd = __intVal(aFileDescriptor);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4499
	int lockArg;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4500
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4501
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4502
	 * claus: sigh - each one has a different interface ... 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4503
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4504
#if defined(F_SETLK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4505
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4506
	    /* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4507
	     * new fcntl(SETLK) interface;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4508
	     * available on SYSV4 and Linux
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4509
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4510
	    struct flock flock;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4511
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4512
	    if (isSharedReadLock == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4513
		flock.l_type = F_RDLCK;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4514
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4515
		flock.l_type = F_WRLCK;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4516
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4517
	    flock.l_whence = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4518
	    flock.l_start = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4519
	    flock.l_len = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4520
	    lockArg = F_SETLK;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4521
# if defined(F_SETLKW)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4522
	    if (blockIfLocked == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4523
		lockArg = F_SETLKW;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4524
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4525
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4526
	    if (fcntl(fd, lockArg, &flock) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4527
		RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4528
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4529
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4530
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4531
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4532
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4533
# if defined(LOCK_EX) && defined(LOCK_UN)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4534
	/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4535
	 * BSD 4.3 advisory locks
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4536
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4537
	lockArg = LOCK_EX;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4538
#  if defined(LOCK_SH)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4539
	if (isSharedReadLock == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4540
	    lockArg = LOCK_SH
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4541
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4542
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4543
#  if defined(LOCK_NB)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4544
	if (blockIfLocked == false) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4545
	    lockArg |= LOCK_NB;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4546
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4547
#  endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4548
	if (flock(fd, lockArg) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4549
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4550
	}
3496
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
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4553
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4554
#  if defined(F_LOCK) && defined(F_UNLOCK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4555
	/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4556
	 * SYSV3 advisory locks
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4557
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4558
	if (lockf(fd, F_LOCK, 0) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4559
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4560
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4561
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4562
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4563
#endif
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
    ^ false
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4569
supportsFileLinks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4570
    "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
  4571
     Typically, only unix returns true here."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4572
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4573
    ^ true
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4574
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4575
    "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
  4576
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4577
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4578
supportsFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4579
    "return true, if the OS supports file locking"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4580
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4581
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4582
#if defined(F_SETLK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4583
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4584
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4585
# if defined(LOCK_EX) && defined(LOCK_UN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4586
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4587
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4588
#  if defined(F_LOCK) && defined(F_UNLOCK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4589
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4590
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4591
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4592
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4593
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4594
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4595
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4596
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4597
     OperatingSystem supportsFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4598
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4599
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4600
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4601
supportsNonBlockingFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4602
    "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
  4603
     (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
  4604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4605
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4606
#if defined(F_SETLK) && defined(F_SETLKW)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4607
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4608
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4609
# 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
  4610
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4611
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4612
#endif
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
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4615
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4616
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4617
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4618
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4619
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4620
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4621
supportsSharedLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4622
    "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
  4623
     file locking."
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
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4626
#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
  4627
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4628
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4629
# 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
  4630
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4631
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4632
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4633
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4634
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4635
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4636
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4637
     OperatingSystem supportsNonBlockingFileLocks
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4641
unlockFD:aFileDescriptor
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4642
    "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
  4643
     which was previously aquired by #lockFD:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4644
     Return false, if the unlock failed 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4645
     (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
  4646
      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
  4647
     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
  4648
     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
  4649
     
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4650
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4651
    if (__isSmallInteger(aFileDescriptor)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4652
	int fd = __intVal(aFileDescriptor);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4653
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4654
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4655
	 * claus: sigh - each one has a different interface ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4656
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4657
#if defined(F_SETLK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4658
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4659
	    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4660
	     * new fcntl(SETLK) interface;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4661
	     * available on SYSV4 and Linux
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4662
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4663
	    struct flock flock;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4664
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4665
	    flock.l_type = F_UNLCK;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4666
	    flock.l_whence = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4667
	    flock.l_start = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4668
	    flock.l_len = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4669
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4670
		RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4671
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4672
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4673
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4674
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4675
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4676
# if defined(LOCK_EX) && defined(LOCK_UN)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4677
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4678
	 * BSD 4.3 advisory locks
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4679
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4680
	if (flock(fd, LOCK_UN) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4681
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
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
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4685
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4686
#  if defined(F_LOCK) && defined(F_UNLOCK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4687
	/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4688
	 * SYSV3 advisory locks
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4689
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4690
	if (lockf(fd, F_UNLOCK, 0) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4691
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4692
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4693
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4694
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4695
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4696
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4697
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4698
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4699
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4701
!UnixOperatingSystem class methodsFor:'file queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4702
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4703
caseSensitiveFilenames
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4704
    "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
  4705
     On MSDOS, this will return false; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4706
     on a real OS, we return true."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4707
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4708
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4709
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4710
    "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
  4711
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4712
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4713
compressPath:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4714
    "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
  4715
     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
  4716
     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
  4717
     if realPath and popen failed."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4718
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4719
    |names n "{ Class: SmallInteger }" |
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4720
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4721
    names := pathName 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4722
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4723
    names := names asOrderedCollection.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4724
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4725
     cut off initial double-slashes
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4726
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4727
    [names startsWith:#('' '')] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4728
	names removeFirst.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4729
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4730
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4731
     cut off double-slashes at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4732
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4733
    [names endsWith:#('')] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4734
	names removeLast.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4735
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4736
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4737
     cut off current-dir at beginning
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4738
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4739
    n := names size.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4740
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4741
	names removeFirst.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4742
	n := n - 1.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4743
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4744
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4745
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4746
     cut off parent-dirs at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4747
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4748
    [(n > 2) 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4749
     and:[(names endsWith:#('..'))
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4750
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4751
	names removeLast; removeLast.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4752
	n := n - 2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4753
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4755
    ^ names asStringWith:self fileSeparator 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4756
		    from:1
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4757
		    to:n
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4758
		    compressTabs:false final:nil 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4759
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4760
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4761
     OperatingSystem compressPath:'./..'    
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4762
     OperatingSystem compressPath:'/foo/bar/baz/..'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4763
     OperatingSystem compressPath:'foo/bar/baz/..'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4764
     OperatingSystem compressPath:'foo/bar/baz/../'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4765
     OperatingSystem compressPath:'foo/bar/baz/..///' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4766
     OperatingSystem compressPath:'///foo/bar/baz/..///' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4767
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4768
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4769
    "Modified: 1.11.1996 / 20:13:48 / cg"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4772
fileSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4773
    "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
  4774
     This character differs for MSDOS and other systems,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4775
     (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
  4776
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4777
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4778
    ^ $/
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4779
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4780
    "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
  4781
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4782
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4783
getDiskInfoOf:aDirectoryPath
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4784
    "return some disk info. 
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4785
     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
  4786
     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
  4787
     On unix, the information returned is (at least):
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4788
	freeBytes
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4789
	totalBytes
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4790
    "
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4791
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4792
    |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
  4793
     fileSystemIdx sizeIdx usedIdx availIdx capacityIdx mountIdx|
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4794
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4795
    p := PipeStream readingFrom:('df -k ' , aDirectoryPath).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4796
    p isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4797
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4798
    [
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4799
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4800
    ] ensure:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4801
	p close.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4802
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4803
"/ Transcript showCR:outputText asString.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4804
    outputText isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4805
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4806
    outputText := outputText asCollectionOfLines.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4807
    outputText size < 2 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4808
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4809
    keys := (outputText at:1) asLowercase asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4810
    values := (outputText at:2) asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4811
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4812
    "/ 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
  4813
    "/ on some rude Unix versions ...
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4814
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4815
    fileSystemIdx := 1.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4816
    sizeIdx := 2.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4817
    usedIdx := 3.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4818
    availIdx := 4.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4819
    capacityIdx := 5.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4820
    mountIdx := 6.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4821
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4822
    values size < 6 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4823
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4824
    info := IdentityDictionary new.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4825
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4826
    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
  4827
    n notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4828
	info at:#percentUsed put:n
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4829
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4830
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4831
    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
  4832
    n notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4833
	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
  4834
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4835
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4836
    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
  4837
    n notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4838
	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
  4839
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4840
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4841
    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
  4842
    n notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4843
	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
  4844
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4845
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4846
    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
  4847
    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
  4848
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4849
    ^ info
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4850
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4851
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4852
     OperatingSystem getDiskInfoOf:'/'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4853
     OperatingSystem getDiskInfoOf:'.'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4854
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4855
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4856
    "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
  4857
!
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4858
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4859
getDriveList
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4860
    "return a list of volumes in the system. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4861
     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
  4862
     - 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
  4863
     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
  4864
     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
  4865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4866
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4867
    "/ default: retrurn array filled with
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4868
    "/ root, home and current directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4869
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4870
    ^ Array 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4871
	with:'/'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4872
	with:(self getHomeDirectory)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4873
	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
  4874
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4875
    "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
  4876
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4877
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4878
getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4879
    "return info about mounted volumes. 
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4880
     The amount of information returned depends upon the OS, and is
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4881
     not guaranteed to be consistent across architectures.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4882
     On unix, the information returned is (at least):
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4883
	mountPoint - mount point
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4884
	fileSystem - device or NFS-remotePath
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4885
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4886
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4887
    |p outputText keys values info infoEntry|
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4888
4933
bfa38904104e use df -k
Claus Gittinger <cg@exept.de>
parents: 4923
diff changeset
  4889
    p := PipeStream readingFrom:('df -k').
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4890
    p isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4891
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4892
    [
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4893
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4894
    ] ensure:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4895
	p close.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4896
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4897
"/ Transcript showCR:outputText asString.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4898
    outputText isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4899
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4900
    outputText := outputText asCollectionOfLines.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4901
    outputText size < 2 ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4902
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4903
    keys := (outputText at:1) asLowercase asCollectionOfWords.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4904
    "/ we may have to validate the following column indices
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4905
    "/ on some rude Unix versions ...
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4906
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4907
    info := OrderedCollection new.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4908
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4909
    outputText from:2 do:[:line |
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4910
	values := line asCollectionOfWords.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4911
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4912
	values size >= 2 ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4913
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4914
	    infoEntry := IdentityDictionary new.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4915
	    infoEntry at:#mountPoint put:(values last).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4916
	    infoEntry at:#fileSystem put:(values first).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4917
	    info add:infoEntry.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4918
	]
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4919
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4920
    ^ info
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4921
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4922
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4923
     OperatingSystem getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4924
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4925
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4926
    "Modified: / 22.5.1999 / 00:32:13 / cg"
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4927
!
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4928
4201
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4929
getNullDevice
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4930
    "return the name of the OS's null device"
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4931
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4932
    ^ '/dev/null'
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4933
!
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4934
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4935
infoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4936
    "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
  4937
     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
  4938
     the returned object) is:
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4939
	 type            - a symbol giving the files type
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4940
	 mode            - numeric access mode 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4941
	 uid             - owners user id
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4942
	 gid             - owners group id
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4943
	 size            - files size
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4944
	 id              - files number (i.e. inode number)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4945
	 accessed        - last access time (as Timestamp)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4946
	 modified        - last modification time (as Timestamp)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4947
	 statusChanged   - last status change time (as Timestamp)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4948
	 alternativeName     - (windows only:) the MSDOS name of the file
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4949
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4950
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4951
	 recordAttributes    - (VMS only:) recordAttributes
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4952
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4953
	 recordSize          - (VMS only:) record size.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4954
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4955
     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
  4956
     all of the information.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4957
     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
  4958
     For symbolic links (if supported by the OS), 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4959
     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
  4960
     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
  4961
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4962
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
  4963
    |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
  4964
     atime mtime ctime 
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  4965
     aOStime mOStime cOStime|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4966
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4967
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4968
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4969
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4970
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4971
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4972
# ifdef TRACE_STAT_CALLS
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4973
	printf("stat on '%s' for info\n", __stringVal(aPathName));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4974
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4975
	__BEGIN_INTERRUPTABLE__
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4976
	do {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4977
	    ret = stat((char *) __stringVal(aPathName), &buf);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4978
	} while ((ret < 0) && (errno == EINTR));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4979
	__END_INTERRUPTABLE__
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4980
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4981
	if (ret < 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4982
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4983
	    RETURN ( nil );
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4984
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4985
	switch (buf.st_mode & S_IFMT) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4986
	    case S_IFDIR:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4987
		type = @symbol(directory);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4988
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4989
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4990
	    case S_IFREG:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4991
		type = @symbol(regular);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4992
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4993
# ifdef S_IFCHR
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4994
	    case S_IFCHR:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4995
		type = @symbol(characterSpecial);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4996
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4997
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4998
# ifdef S_IFBLK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  4999
	    case S_IFBLK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5000
		type = @symbol(blockSpecial);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5001
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5002
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5003
# ifdef S_IFMPC
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5004
	    case S_IFMPC:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5005
		type = @symbol(multiplexedCharacterSpecial);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5006
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5007
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5008
# ifdef S_IFMPB
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5009
	    case S_IFMPB:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5010
		type = @symbol(multiplexedBlockSpecial);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5011
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5012
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5013
# ifdef S_IFLNK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5014
	    case S_IFLNK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5015
		type = @symbol(symbolicLink);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5016
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5017
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5018
# ifdef S_IFSOCK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5019
	    case S_IFSOCK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5020
		type = @symbol(socket);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5021
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5022
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5023
# ifdef S_IFIFO
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5024
	    case S_IFIFO:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5025
		type = @symbol(fifo);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5026
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5027
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5028
	    default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5029
		type = @symbol(unknown);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5030
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5031
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5032
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5033
	ino = buf.st_ino;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5034
	id = __MKUINT(ino);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5035
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5036
	mode = __MKSMALLINT(buf.st_mode & 0777);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5037
	uid = __MKSMALLINT(buf.st_uid);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5038
	gid = __MKSMALLINT(buf.st_gid);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5039
	nLink = __MKSMALLINT(buf.st_nlink);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5040
	size = __MKUINT(buf.st_size);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5041
	aOStime = __MKUINT(buf.st_atime);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5042
	mOStime = __MKUINT(buf.st_mtime);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5043
	cOStime = __MKUINT(buf.st_ctime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5044
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5045
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5046
    mode notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5047
	atime := AbsoluteTime fromOSTime:(aOStime * 1000).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5048
	mtime := AbsoluteTime fromOSTime:(mOStime * 1000).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5049
	ctime := AbsoluteTime fromOSTime:(cOStime * 1000).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5050
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5051
	info := FileStatusInfo
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5052
		    type:type 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5053
		    mode:mode 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5054
		    uid:uid 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5055
		    gid:gid 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5056
		    size:size 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5057
		    id:id 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5058
		    accessed:atime 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5059
		    modified:mtime 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5060
		    statusChanged:ctime
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5061
		    path:nil
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5062
		    numLinks:nLink.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5063
	^ info
3496
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
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5066
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5067
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5068
    OperatingSystem infoOf:'/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5069
    (OperatingSystem infoOf:'/') uid
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5070
    (OperatingSystem infoOf:'/') accessed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5071
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5072
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5073
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5074
isDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5075
    "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
  5076
     (i.e. exists and is a directory).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5077
     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
  5078
     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
  5079
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5080
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5081
    int ret;
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
    if (__isString(aPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5084
	struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5085
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5086
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5087
	printf("stat on '%s' for isDirectory\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5088
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5089
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5090
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5091
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5092
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5093
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5094
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5095
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5096
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5097
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5098
	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
  5099
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5100
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5101
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5102
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5103
    "an alternative implementation would be:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5104
	^ (self infoOf:aPathName) type == #directory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5105
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5106
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5108
isExecutable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5109
    "return true, if the given file is executable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5110
     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
  5111
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5112
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5113
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5115
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5116
# ifdef TRACE_ACCESS_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5117
	printf("access on '%s' for executable\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5118
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5119
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5120
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5121
	    ret = access(__stringVal(aPathName), X_OK);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5122
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5123
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5124
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5125
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5126
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5127
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5128
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5129
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5130
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5131
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5132
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5133
isReadable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5134
    "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
  5135
     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
  5136
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5137
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5138
    int ret;
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
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5141
# ifdef TRACE_ACCESS_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5142
	printf("access on '%s' for readable\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5143
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5144
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5145
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5146
	    ret = access(__stringVal(aPathName), R_OK);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5147
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5148
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5149
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5150
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5151
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5152
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5153
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5154
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5155
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5156
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5157
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5158
isSymbolicLink:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5159
    "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
  5160
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5161
    ^ (self linkInfoOf:aPathName) notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5162
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5163
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5164
     OperatingSystem isSymbolicLink:'Make.proto'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5165
     OperatingSystem isSymbolicLink:'Makefile' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5166
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5167
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5168
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5169
isValidPath:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5170
    "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
  5171
     (i.e. the file or directory exists)"
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
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5175
    int ret;
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
    if (__isString(aPathName) || __isSymbol(aPathName) ) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5178
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5179
	printf("stat on '%s' for isValidPath\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5180
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5181
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5182
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5183
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5184
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5185
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5186
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5187
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5188
	    RETURN (false);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5189
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5190
	RETURN ( ret ? false : true );
3496
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5193
    ^ self primitiveFailed
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5194
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5195
"/ alternative:
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5196
"/        ^ (self infoOf:aPathName) notNil
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  5197
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5198
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5199
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5200
isWritable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5201
    "return true, if the given file is writable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5202
     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
  5203
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5204
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5205
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5206
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5207
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5208
# ifdef TRACE_ACCESS_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5209
	printf("access on '%s' for writable\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5210
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5211
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5212
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5213
	    ret = access(__stringVal(aPathName), W_OK);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5214
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5215
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5216
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5217
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5218
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5219
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5220
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5221
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5222
    ^ self primitiveFailed
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5225
linkInfoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5226
    "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
  5227
     IFF aPathName is a symbolic link. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5228
     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
  5229
     (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
  5230
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5231
     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
  5232
     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
  5233
     in case of a symbolic link."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5234
     
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
  5235
    |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
  5236
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5237
%{  /* STACK: 1200 */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  5238
#if defined(S_IFLNK)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5239
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5240
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5241
    char pathBuffer[1024];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5242
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5243
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5244
    if (__isString(aPathName)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5245
	__BEGIN_INTERRUPTABLE__
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5246
	do {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5247
	    ret = lstat((char *) __stringVal(aPathName), &buf);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5248
	} while ((ret < 0) && (errno == EINTR));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5249
	__END_INTERRUPTABLE__
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5250
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5251
	if (ret < 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5252
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5253
	    RETURN ( nil );
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5254
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5255
	switch (buf.st_mode & S_IFMT) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5256
	    default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5257
		RETURN ( nil ); /* not a symbolic link */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5258
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5259
	    case S_IFLNK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5260
		type = @symbol(symbolicLink);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5261
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5262
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5263
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5264
	ino = buf.st_ino;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5265
	id = __MKUINT(ino);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5266
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5267
	mode = __MKSMALLINT(buf.st_mode & 0777);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5268
	nLink = __MKSMALLINT(buf.st_nlink);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5269
	uid = __MKSMALLINT(buf.st_uid);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5270
	gid = __MKSMALLINT(buf.st_gid);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5271
	size = __MKUINT(buf.st_size);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5272
	atime = __MKUINT(buf.st_atime);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5273
	mtime = __MKUINT(buf.st_mtime);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5274
	ctime = __MKUINT(buf.st_ctime);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5275
	if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5276
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5277
	    RETURN ( nil );
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5278
	} 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5279
	pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5280
	path = __MKSTRING(pathBuffer);
3496
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
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5283
    RETURN ( nil );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5284
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5285
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5286
    mode notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5287
	info := IdentityDictionary new.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5288
	^ FileStatusInfo
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5289
	    type:type 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5290
	    mode:mode 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5291
	    uid:uid 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5292
	    gid:gid 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5293
	    size:size 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5294
	    id:id 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5295
	    accessed:(AbsoluteTime fromOSTime:(atime * 1000)) 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5296
	    modified:(AbsoluteTime fromOSTime:(mtime * 1000)) 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5297
	    statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5298
	    path:path
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5299
	    numLinks:nLink.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5300
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5301
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5302
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5303
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5304
    OperatingSystem infoOf:'Make.proto'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5305
    OperatingSystem linkInfoOf:'Make.proto' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5306
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5307
    OperatingSystem infoOf:'resources/motif.style'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5308
    OperatingSystem linkInfoOf:'resources/motif.style' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5309
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5310
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5311
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5312
parentDirectoryName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5313
    "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
  5314
     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
  5315
     for other systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5316
     (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
  5317
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5318
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5319
    ^ '..'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5320
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5321
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5322
pathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5323
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5324
     - 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
  5325
     This method needs the path to be valid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5326
     (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
  5327
     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
  5328
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5329
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5330
    |p path command|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5332
    "some systems have a convenient function for this ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5333
    path := self primPathNameOf:pathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5334
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5335
    path isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5336
	(self isValidPath:pathName) ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5337
	    p := pathName.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5338
	    [(p size > 1)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5339
	     and:[p endsWith:(self fileSeparator)]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5340
	    ] whileTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5341
		p := p copyWithoutLast:1.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5342
	    ].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5343
	    ^ p
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5344
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5345
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5346
	(SlowFork==true or:[PipeFailed==true]) ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5347
	    PipeStream openErrorSignal handle:[:ex |
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5348
		PipeFailed := true.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5349
		'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5350
		ex return.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5351
	    ] do:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5352
		"have to fall back ..."
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5353
		command := 'cd "' , pathName , '"; pwd'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5354
		p := PipeStream readingFrom:command.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5355
	    ].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5356
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5357
	    (p isNil or:[p atEnd]) ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5358
		('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5359
	    ] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5360
		path := p nextLine.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5361
		p close.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5362
	    ]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5363
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5364
	path isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5365
	    "/
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5366
	    "/ return the original - there is nothing else can we do
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5367
	    "/
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5368
	    path := pathName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5369
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5370
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5371
	    path := self compressPath:path
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5372
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5373
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5374
    ^ path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5375
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5376
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5377
     OperatingSystem pathNameOf:'.'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5378
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5379
     OperatingSystem pathNameOf:'../../..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5380
     OperatingSystem pathNameOf:'..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5381
     OperatingSystem pathNameOf:'/tmp////' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5382
     OperatingSystem pathNameOf:'/foo/bar' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5383
     OperatingSystem pathNameOf:'/foo/bar/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5384
     OperatingSystem pathNameOf:'/foo/bar//'
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
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5387
    "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
  5388
    "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
  5389
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5390
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5391
primIdOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5392
    "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
  5393
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5394
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5395
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5396
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5397
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5398
    OBJ retVal;
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
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5401
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5402
	printf("stat on '%s' for id\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5403
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5404
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5405
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5406
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5407
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5408
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5409
	if (ret >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5410
	    ino = buf.st_ino;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5411
	    retVal = __MKUINT(ino);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5412
	    RETURN (retVal);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5413
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5414
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5415
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5416
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5417
    RETURN (nil);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5418
%}.
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
5492
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5421
primInfoOf:aPathName
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5422
   "for rel5 only"
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5423
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5424
   ^ self primitiveFailed
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5425
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5426
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5427
!
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5428
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5429
primPathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5430
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5431
     - 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
  5432
     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
  5433
     realPath library function.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5434
     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
  5435
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5436
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5437
    |path|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5438
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5439
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5440
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5441
    if (__isString(pathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5442
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5443
#ifdef HAS_GETCWD
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5444
	if (strcmp(__stringVal(pathName), ".") == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5445
	    char nameBuffer[MAXPATHLEN + 1];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5446
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5447
	    if (@global(CurrentDirectory) == nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5448
		if (getcwd(nameBuffer, MAXPATHLEN)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5449
		    OBJ d;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5450
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5451
		    @global(CurrentDirectory) = d = __MKSTRING(nameBuffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5452
		    __GSTORE(d);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5453
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5454
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5455
	    RETURN (@global(CurrentDirectory));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5456
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5457
#endif /* HAS_GETCWD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5458
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5459
#ifdef HAS_REALPATH
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5460
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5461
	    char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5462
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5463
	    if (realpath(__stringVal(pathName), nameBuffer)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5464
		RETURN ( __MKSTRING(nameBuffer) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5465
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5466
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5467
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5468
#endif /* ! HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5469
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5470
%}.
5451
2e21cd54b656 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5448
diff changeset
  5471
    ^ nil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5472
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5473
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5474
timeOfLastAccess:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5475
    "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
  5476
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5477
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5478
    "could be implemented as:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5479
	(self infoOf:aPathName) accessed 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5480
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5481
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5482
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5483
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5484
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5485
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5486
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5487
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5488
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5489
	printf("stat on '%s' for timeOfLastAccess\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5490
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5491
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5492
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5493
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5494
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5495
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5496
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5497
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5498
	    RETURN (nil);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5499
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5500
	osSeconds = __MKUINT(buf.st_atime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5501
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5502
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5503
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5504
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5505
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5506
    i notNil ifTrue:[^ i accessed].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5507
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5508
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5509
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5510
     OperatingSystem timeOfLastAccess:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5511
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5512
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5513
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5514
timeOfLastChange:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5515
    "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
  5516
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5517
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5518
    "could be implemented as:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5519
	(self infoOf:aPathName) modified
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5520
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5521
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5522
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5523
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5524
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5525
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5526
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5527
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5528
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5529
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5530
	printf("stat on '%s' for timeOfLastChange\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5531
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5532
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5533
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5534
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5535
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5536
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5537
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5538
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5539
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5540
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5541
	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
  5542
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5543
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5544
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5545
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5546
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5547
    i notNil ifTrue:[^ i modified].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5548
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5549
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5550
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5551
     OperatingSystem timeOfLastChange:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5552
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5553
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5554
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5555
typeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5556
    "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
  5557
     nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5558
     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
  5559
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5560
    |i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5561
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5562
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5563
     this could have been implemented as:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5564
	(self infoOf:aPathName) type 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5565
     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
  5566
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5567
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5568
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5569
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5570
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5571
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5572
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5573
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5574
	printf("stat on '%s' for type\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5575
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5576
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5577
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5578
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5579
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5580
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5581
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5582
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5583
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5584
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5585
	switch (buf.st_mode & S_IFMT) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5586
	    case S_IFDIR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5587
		RETURN ( @symbol(directory) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5588
	    case S_IFREG:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5589
		RETURN ( @symbol(regular) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5590
# ifdef S_IFCHR
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5591
	    case S_IFCHR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5592
		RETURN ( @symbol(characterSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5593
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5594
# ifdef S_IFBLK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5595
	    case S_IFBLK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5596
		RETURN ( @symbol(blockSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5597
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5598
# ifdef S_IFLNK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5599
	    case S_IFLNK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5600
		RETURN ( @symbol(symbolicLink) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5601
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5602
# ifdef S_IFSOCK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5603
	    case S_IFSOCK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5604
		RETURN ( @symbol(socket) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5605
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5606
# ifdef S_IFIFO
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5607
	    case S_IFIFO:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5608
		RETURN ( @symbol(fifo) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5609
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5610
	    default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5611
		RETURN ( @symbol(unknown) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5612
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5613
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5614
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5615
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5616
    i notNil ifTrue:[^ i type].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5617
    ^ nil.
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5620
     OperatingSystem typeOf:'/'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5621
     OperatingSystem typeOf:'.'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5622
     OperatingSystem typeOf:'Make.proto' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5623
     OperatingSystem typeOf:'resources/motif.style' 
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5627
volumeNameOf:aPathString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5628
    "return the volumeName of the argument, aPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5629
     - thats the name of the volume where aPath is.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5630
     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
  5631
     this always returns an empty string."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5632
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5633
    ^ ''
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5634
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5635
    "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
  5636
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5637
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5638
!UnixOperatingSystem class methodsFor:'interrupts & signals'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5639
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5640
defaultSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5641
    "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
  5642
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5643
     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
  5644
     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
  5645
     default for SIGQUIT (^ \) is to dump core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5646
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5647
     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
  5648
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5649
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5650
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5651
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5652
    if (__isSmallInteger(signalNumber)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5653
#ifdef SIG_DFL
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5654
	signal(__intVal(signalNumber), SIG_DFL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5655
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5656
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5657
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5658
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5659
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5660
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5661
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5662
    ^ self primitiveFailed
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
    "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
  5665
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5666
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5667
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5668
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5669
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5670
     'normal ^C handling again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5671
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5672
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5673
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5674
disableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5675
    "turn off IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5676
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5677
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5678
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5679
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5680
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5681
#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
  5682
    if (__isSmallInteger(fd)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5683
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5684
# if defined(SYSV4)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5685
	ret = ioctl(f, I_SETSIG, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5686
# else /*! SYSV4*/
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5687
	flags = fcntl(f, F_GETFL, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5688
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5689
	 * if already clear, there is no need for this syscall ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5690
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5691
	if (flags & FASYNC) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5692
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5693
	    if (ret >= 0) ret = flags;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5694
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5695
	    ret = flags;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5696
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5697
# endif /* !SYSV4 */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5698
	RETURN ( __MKSMALLINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5699
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5700
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5701
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5702
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5703
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5704
     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
  5705
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5706
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5707
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5708
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5709
disableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5710
    "disable (Unix-) signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5711
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5712
     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
  5713
     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
  5714
     handling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5715
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5716
     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
  5717
     a signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5718
     Use only for fully debugged stand alone applications."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5719
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5720
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5721
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5722
    if (__isSmallInteger(signalNumber)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5723
	int sigNo = __intVal(signalNumber);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5724
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5725
	if (sigNo == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5726
	    RETURN (self);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5727
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5728
#ifdef SIG_IGN
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5729
	signal(sigNo, SIG_IGN);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5730
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5731
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5732
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5733
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5734
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5735
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5736
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5737
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5738
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5739
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5740
     'now, ^C is totally ignored ...' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5741
     OperatingSystem disableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5742
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5743
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5744
     '^C handled again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5745
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5746
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5747
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5748
disableTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5749
    "disable timer interrupts.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5750
     WARNING: 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5751
	the system will not operate correctly with timer interrupts
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5752
	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
  5753
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5754
%{  /* NOCONTEXT */
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
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5757
    struct itimerval dt;
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
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5760
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5761
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5762
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5763
    setitimer(ITIMER_REAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5764
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5765
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5766
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5767
# if defined(USE_SLOW_ALARM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5768
#  if defined(SIGALRM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5769
    alarm(0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5770
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5771
#  endif /* SIGALRM */
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5775
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5776
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5777
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5778
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5779
enableChildSignalInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5780
    "enable childSignal interrupts 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5781
     (SIGCHLD, if the architecture supports it).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5782
     After enabling, these signals will send the message 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5783
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5784
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5785
    self enableSignal:(self sigCHLD)
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5788
enableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5789
    "turn on IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5790
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5791
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5792
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5793
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5794
#ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5795
    extern void __signalIoInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5796
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5797
    static int firstCall = 1;
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
#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
  5800
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5801
 * SIGIO/SIGPOLL - data available for I/O
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5802
 * (used to wake up waiting processes)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5803
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5804
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5805
# define THESIGNAL SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5806
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5807
# ifdef SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5808
#  define THESIGNAL SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5809
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5810
#  ifdef SIGURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5811
#   define THESIGNAL SIGURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5812
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5813
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5814
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5815
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5816
    if (__isSmallInteger(fd)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5817
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5818
#ifdef HAS_SIGACTION
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5819
	    struct sigaction act = {0};
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5820
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5821
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5822
	     * Do not add SA_RESTART here. A signal can cause a
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5823
	     * thread switch, another thread can do a garbage collect
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5824
	     * and restarted system calls may write into old
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5825
	     * (collected) addresses.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5826
	     */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5827
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5828
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5829
	    sigemptyset(&act.sa_mask);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5830
	    act.sa_handler = __signalIoInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5831
	    sigaction(THESIGNAL, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5832
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5833
# ifdef HAS_SIGVEC
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5834
	    struct sigvec vec;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5835
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5836
	    vec.sv_flags = SV_INTERRUPT;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5837
	    sigemptyset(&vec.sv_mask);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5838
	    vec.sv_handler = __signalIoInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5839
	    sigvec(THESIGNAL, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5840
# else
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5841
	    signal(THESIGNAL, __signalIoInterrupt);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5842
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5843
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5844
	    firstCall = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5845
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5846
#undef THESIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5847
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5848
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5849
# if defined(SYSV4)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5850
	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
  5851
# else /*! SYSV4*/
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5852
	flags = fcntl(f, F_GETFL, 0);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5853
	/*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5854
	 * if already set, there is no need for this syscall ...
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5855
	 */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5856
	if (flags & FASYNC) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5857
	    ret = flags;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5858
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5859
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5860
	    if (ret >= 0) ret = flags;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5861
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5862
# endif /*!SYSV4*/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5863
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5864
#if defined(F_SETOWN) || defined(FIOSETOWN)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5865
	{
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5866
	    int pid;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5867
	    int ok;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5868
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5869
	    pid = getpid();
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5870
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5871
# if defined(F_SETOWN)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5872
	    ok = fcntl(f, F_SETOWN, pid);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5873
	    /* 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
  5874
# else
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5875
	    ok = ioctl(f, FIOSETOWN, &pid);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5876
	    /* printf("FIOSETOWN returns %d (%d)\n", ret, errno); */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5877
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5878
	    if (ok < 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5879
		ret = ok;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5880
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5881
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5882
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5883
	RETURN ( __MKUINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5884
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5885
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5886
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5887
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5888
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5889
     or if the system does not support SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5890
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5891
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5892
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5893
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5894
enableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5895
    "enable (Unix-)signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5896
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5897
     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
  5898
     (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
  5899
     sends #signalInterrupt:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5900
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5901
     NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5902
     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
  5903
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5904
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5905
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5906
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5907
#ifdef NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5908
# define SIG_LIMIT NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5909
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5910
# ifdef SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5911
#  define SIG_LIMIT SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5912
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5913
#  ifdef SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5914
#   define SIG_LIMIT SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5915
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5916
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5917
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5918
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5919
#if defined(SIGPOLL) && !defined(SIGIO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5920
# define SIGIO SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5921
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5922
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5923
#ifdef SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5924
# define CHILD_SIGNAL   SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5925
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5926
# ifdef SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5927
#  define CHILD_SIGNAL  SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5928
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5929
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5930
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5931
    int sigNr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5932
#if defined(SIGINT) || defined(SIGQUIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5933
# ifndef __signalUserInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5934
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5935
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5936
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5937
#ifdef SIGFPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5938
# ifndef __signalFpExceptionInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5939
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5940
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5941
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5942
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5943
# ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5944
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5945
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5946
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5947
#ifdef CHILD_SIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5948
# ifndef __signalChildInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5949
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5950
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5951
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5952
#ifdef SIGPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5953
# ifndef __signalPIPEInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5954
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5955
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5956
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5957
#ifdef SIGBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5958
# ifndef __signalBUSInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5959
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5960
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5961
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5962
#ifdef SIGSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5963
# ifndef __signalSEGVInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5964
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5965
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5966
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5967
#if defined(SIGILL) || defined(SIGEMT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5968
# ifndef __signalTrapInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5969
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5970
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5971
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5972
#ifdef SIGALRM
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
  5973
# ifndef __signalTimerInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5974
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5975
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5976
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5977
#ifndef __signalInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5978
    extern void __signalInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5979
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5980
    void (*handler)(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5981
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5982
    if (__isSmallInteger(signalNumber)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5983
     && ((sigNr = __intVal(signalNumber)) >= 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5984
#ifdef SIG_LIMIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5985
     &&  (sigNr <= SIG_LIMIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5986
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5987
    ) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5988
	/*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5989
	 * standard signals are forced into standard handlers
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5990
	 * - all others go into general signalInterrupt
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5991
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5992
#if defined(SIGPOLL) && defined(SIGIO)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5993
	if (sigNr == SIGPOLL)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5994
	    sigNr = SIGIO;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5995
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5996
	switch (sigNr) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5997
	    case 0:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5998
		/* enabling a non-supported signal */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  5999
		RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6000
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6001
#ifdef SIGBREAK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6002
	    case SIGBREAK:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6003
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6004
#ifdef SIGINT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6005
	    case SIGINT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6006
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6007
#ifdef SIGQUIT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6008
	    case SIGQUIT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6009
#endif
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  6010
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6011
		handler = __signalUserInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6012
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6013
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6014
#ifdef SIGFPE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6015
	    case SIGFPE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6016
		handler = __signalFpExceptionInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6017
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6018
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6019
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6020
#ifdef SIGPIPE
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6021
	    case SIGPIPE:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6022
		handler = __signalPIPEInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6023
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6024
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6025
#ifdef SIGBUS
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6026
	    case SIGBUS:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6027
		handler = __signalBUSInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6028
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6029
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6030
#ifdef SIGSEGV
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6031
	    case SIGSEGV:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6032
		handler = __signalSEGVInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6033
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6034
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6035
#ifdef SIGILL
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6036
	    case SIGILL:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6037
		handler = __signalTrapInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6038
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6039
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6040
#ifdef SIGEMT
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6041
	    case SIGEMT:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6042
		handler = __signalTrapInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6043
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6044
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6045
#ifdef SIGIO
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6046
	    case SIGIO:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6047
		handler = __signalIoInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6048
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6049
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6050
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6051
#ifdef CHILD_SIGNAL
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6052
	    case CHILD_SIGNAL:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6053
		handler = __signalChildInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6054
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6055
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6056
#ifdef SIGALRM
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6057
	    case SIGALRM:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6058
		handler = __signalTimerInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6059
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6060
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6061
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6062
	    default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6063
		handler = __signalInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6064
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6065
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6066
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6067
	{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6068
#ifdef HAS_SIGACTION
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6069
	    struct sigaction act = {0};
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6070
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6071
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6072
	     * Do not add SA_RESTART here. A signal can cause a
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6073
	     * thread switch, another thread can do a garbage collect
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6074
	     * and restarted system calls may write into old
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6075
	     * (collected) addresses.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6076
	     */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6077
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6078
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6079
	    sigemptyset(&act.sa_mask);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6080
	    act.sa_handler = handler;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6081
	    sigaction(sigNr, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6082
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6083
# ifdef HAS_SIGVEC
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6084
	    struct sigvec vec;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6085
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6086
	    vec.sv_flags = SV_INTERRUPT;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6087
	    sigemptyset(&vec.sv_mask);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6088
	    vec.sv_handler = handler;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6089
	    sigvec(sigNr, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6090
# else
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6091
	    (void) signal(sigNr, handler);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6092
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6093
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6094
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6095
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6096
	/*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6097
	 * maybe, we should ret the old enable-status
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6098
	 * as boolean here ...
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6099
	 */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6100
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6101
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6102
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6103
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6104
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6105
     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
  6106
     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
  6107
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6108
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6109
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6110
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6111
enableTimer:milliSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6112
    "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
  6113
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6114
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6115
    int millis;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6116
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6117
    millis = __intVal(milliSeconds);
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
#ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6120
    {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6121
	static int firstCall = 1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6122
# ifndef __signalTimerInterrupt
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6123
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6124
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6125
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6126
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6127
# ifdef HAS_SIGACTION
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6128
	    struct sigaction act = {0};
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6129
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6130
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6131
	    sigemptyset(&act.sa_mask);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6132
	    act.sa_handler = __signalTimerInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6133
	    sigaction(SIGALRM, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6134
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6135
#  ifdef HAS_SIGVEC
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6136
	    struct sigvec vec;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6137
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6138
	    vec.sv_flags = SV_INTERRUPT;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6139
	    sigemptyset(&vec.sv_mask);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6140
	    vec.sv_handler = __signalTimerInterrupt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6141
	    sigvec(SIGALRM, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6142
#  else /* neither SIGACTION nor SIGVEC */
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6143
	    signal(SIGALRM, __signalTimerInterrupt);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6144
#  endif /* stupid system  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6145
# endif
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6146
	    firstCall = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6147
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6148
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6149
#endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6150
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6151
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6152
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6153
    {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6154
	struct itimerval dt;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6155
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6156
	dt.it_interval.tv_sec = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6157
	dt.it_interval.tv_usec = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6158
	dt.it_value.tv_sec = millis / 1000;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6159
	dt.it_value.tv_usec = (millis % 1000) * 1000;  
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6160
	setitimer(ITIMER_REAL, &dt, 0);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6161
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6162
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6163
#else /* no ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6165
# ifdef USE_SLOW_ALARM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6166
    {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6167
	/*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6168
	 * last fallback - use alarm (which only gives 1 second resolution).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6169
	 * If the system does not support any of the above, you have to life
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6170
	 * with this. The consequence is that pressing CTRL-C processing and
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6171
	 * thread switching will take place much delayed.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6172
	 */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6173
	alarm(1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6174
	RETURN(true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6175
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6176
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6177
#endif /* ITIMER_REAL */
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
    ^ false
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
6536
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6182
isFatalSignal:aNumber
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6183
   "return true if a signal with number aNumber is a fatal signal,
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6184
    i.e. some severe internal error occured"
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6185
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6186
   ^ (aNumber == self sigSEGV)
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6187
     or:[aNumber == self sigILL
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6188
     or:[aNumber == self sigBUS]]
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6189
!
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  6190
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6191
killProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6192
    "kill a unix process.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6193
     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
  6194
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6195
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6196
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6197
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6198
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6199
    self sendSignal:(self sigKILL) to:processId.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6200
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6201
    "Modified: / 10.6.1998 / 11:59:12 / cg"
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6202
!
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6203
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6204
killProcessGroup:processGroupId
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6205
    "kill a unix process group.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6206
     The process has a no chance to do some cleanup.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6207
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6208
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6209
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6210
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6211
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6212
    self sendSignal:(self sigKILL) to:(processGroupId negated).
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6213
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  6214
    "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
  6215
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6216
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6217
sendSignal:signalNumber to:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6218
    "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
  6219
     Returns false if any error occurred, true otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6220
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6221
     Do not confuse UNIX signals with Smalltalk-Signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6222
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6223
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6224
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6225
	      OperatingSystem>>getStatusOfProcess:aProcessId
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6226
	      if the signal terminates that process."
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
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6229
    if (__bothSmallInteger(signalNumber, processId)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6230
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6231
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6232
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6233
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6234
	RETURN ( true );
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
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6238
    "/ either invalid argument (non-integers)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6239
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6240
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6241
    ^ self primitiveFailed
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6244
startSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6245
    "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
  6246
     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
  6247
     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
  6248
     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
  6249
     (which is of course less correct).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6250
     OBSOLETE: the new messageTally runs as a high prio process, not using 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6251
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6252
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6253
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6254
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6255
#ifndef __spyInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6256
    extern void __spyInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6257
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6258
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6259
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6260
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6261
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6262
# ifdef SIGVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6263
    signal(SIGVTALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6264
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6265
#  ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6266
    signal(SIGALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6267
#  else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6268
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6269
     * mhmh - system has neither SIGBTALRM nor SIGALRM ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6270
     * what should we do here ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6271
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6272
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6273
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6274
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6275
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6276
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6277
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6278
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6279
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6280
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6281
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6282
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6283
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6284
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6285
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6286
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6287
stopSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6288
    "stop spy timing - disable spy timer.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6289
     OBSOLETE: the new messageTally runs as a high prio process, not using 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6290
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6291
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6292
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6293
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6294
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6295
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6296
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6297
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6298
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6299
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6300
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6301
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6302
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6303
#endif /* ITIMER_VIRTUAL */
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
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6306
!
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
terminateProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6309
    "terminate a unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6310
     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
  6311
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6312
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6313
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6314
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6315
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  6316
    self sendSignal:(self sigTERM) to:processId.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6317
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6318
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6319
    "Modified: / 27.1.1998 / 20:05:47 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6320
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6321
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6322
terminateProcessGroup:processGroupId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6323
    "terminate a unix process group.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6324
     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
  6325
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6326
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6327
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6328
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6329
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  6330
    self sendSignal:(self sigTERM) to:(processGroupId negated).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6332
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6333
    "Created: / 23.4.1996 / 16:40:34 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6334
    "Modified: / 27.1.1998 / 20:05:59 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6335
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6336
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6337
!UnixOperatingSystem class methodsFor:'ipc support - UNIX'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6338
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6339
makePTYPair
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6340
    "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
  6341
     nil on failure.
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6342
     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
  6343
     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
  6344
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6345
    |fdS fdM|    
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6346
                
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6347
%{       
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6348
    /*
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6349
     * Find a pseudo tty to use and open both sides.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6350
     *  _fdM receives the master file descriptor while _fdS
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6351
     *  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
  6352
     *  needed in daemons such as rlogind and telnetd.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6353
     */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6354
3536
adad0d12c9a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3534
diff changeset
  6355
#ifdef IRIX5
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6356
    int _fdM, _fdS;
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6357
    char *line;
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6358
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6359
    line = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6360
    if ((line != 0) && (_fdM >= 0)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6361
	_fdS = open(line, O_RDWR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6362
	if (_fdS < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6363
	    (void)close(_fdM);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6364
	    _fdS = _fdM = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6365
	}
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6366
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6367
	_fdM -1;
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6368
    }
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6369
    if ((_fdM >= 0) && (_fdS >= 0)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6370
	 fdM = __MKSMALLINT(_fdM);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6371
	 fdS = __MKSMALLINT(_fdS);
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6372
    }
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6373
#   define NO_PTY_TEMPL
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6374
#endif /* IRIX5 */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6375
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6376
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6377
#ifdef LINUX
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6378
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6379
#   define PT_INDEX      5
3550
6c3824d07eac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  6380
#   define PTY_1_CHARS  "pqrstuabcdevwxyz"
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6381
#   define PTY_2_CHARS  "0123456789abcdef"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6382
#endif /* LINUX */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6383
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6384
#ifdef solaris
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6385
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6386
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6387
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6388
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6389
#endif /* solaris */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6390
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6391
#ifdef aix
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6392
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6393
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6394
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6395
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6396
#endif /* aix */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6397
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6398
#ifdef next3
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6399
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6400
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6401
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6402
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6403
#endif /* next3 */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6404
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6405
#ifdef hpux
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6406
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6407
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6408
#   define PTY_1_CHARS  "pqrs"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6409
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6410
#endif /* hpux */
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6411
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6412
#if defined(__osf__)
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6413
#   define PTY_TEMPL    "/dev/ptyXX"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6414
#   define PT_INDEX      5
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6415
#   define PTY_1_CHARS  "pq"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6416
#   define PTY_2_CHARS  "0123456789abcdef"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6417
#endif /* osf1 */
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6418
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6419
#if defined(BSD) && !defined(PTY_TEMPL)
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6420
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6421
#   define PT_INDEX      5
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6422
#   define PTY_1_CHARS  "p"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6423
#   define PTY_2_CHARS  "0123456789abcdefghijklmnopqrstuv"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6424
#endif /* BSD */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6425
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6426
#ifdef NO_PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6427
# undef PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6428
#endif
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6429
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6430
#ifdef PTY_TEMPL
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6431
#   include <grp.h>
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6432
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6433
# ifdef OLD /* mhmh - suse linux6 places line into rodata ??? */
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6434
    static char line[] = PTY_TEMPL;
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6435
# else
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6436
    char line[128];
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6437
# endif
3575
39723f691a0e hp-cc does not recognize const keyword
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
  6438
    register CONST char *cp1, *cp2;
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6439
    int len, _fdM = -1, _fdS = -1, ttygid;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6440
    struct group *gr;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6441
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6442
# ifdef OLD
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6443
    len = sizeof(PTY_TEMPL) - 1;
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6444
# else
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6445
    strcpy(line, PTY_TEMPL);
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6446
    len = strlen(line);
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6447
# endif
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6448
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6449
    if ((gr = getgrnam("tty")) != NULL)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6450
	ttygid = gr->gr_gid;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6451
    else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6452
	ttygid = -1;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6453
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6454
    for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6455
	line[len-2] = * cp1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6456
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6457
	for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6458
	    line[PT_INDEX] = 'p';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6459
	    line[len-1] = *cp2;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6460
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6461
	    if ((_fdM = open(line, O_RDWR, 0)) < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6462
		if (errno == ENOENT) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6463
		    _fdM = _fdS = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6464
		    goto getOutOfHere; /* out of ptys */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6465
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6466
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6467
		line[PT_INDEX] = 't';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6468
		(void) chown( line, getuid(), ttygid );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6469
		(void) chmod( line, S_IRUSR|S_IWUSR|S_IWGRP );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6470
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6471
		if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6472
		    goto getOutOfHere;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6473
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6474
		(void) close( _fdM );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6475
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6476
	}
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6477
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6478
  getOutOfHere: ;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6479
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6480
    if ((_fdM >= 0) && (_fdS >= 0)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6481
	 fdM = __MKSMALLINT(_fdM);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6482
	 fdS = __MKSMALLINT(_fdS);
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6483
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6484
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6485
#endif /* PTY_TEMPL */
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6486
#undef NO_PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6487
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6488
%}.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6489
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6490
    fdM notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6491
	^ Array with:fdM with:fdS.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6492
    ].
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6493
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6494
    ^ nil
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6495
!
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6496
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6497
makePipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6498
    "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
  6499
     nil on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6500
     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
  6501
     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
  6502
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6503
    |fd1 fd2|    
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6504
                
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6505
%{       
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6506
     int fds[2];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6507
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6508
     if (pipe(fds) < 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6509
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6510
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6511
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6512
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6513
     fd1 = __MKSMALLINT(fds[0]);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6514
     fd2 = __MKSMALLINT(fds[1]);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6515
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6516
    fd1 notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6517
	^ Array with:fd1 with:fd2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6518
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6519
    ^ nil
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6520
!
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6521
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6522
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
  6523
    "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
  6524
%{
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6525
#ifdef TIOCSWINSZ
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6526
    struct winsize wsize;
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6527
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6528
    if (__isSmallInteger(fd)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6529
     && __isSmallInteger(w)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6530
     && __isSmallInteger(h)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6531
	wsize.ws_row = (unsigned short)__intVal(h);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6532
	wsize.ws_col = (unsigned short)__intVal(w);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6533
	if (ioctl(__intVal(fd), TIOCSWINSZ, (char *)&wsize) >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6534
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6535
	}
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6536
    }
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6537
#endif
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6538
%}.
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6539
    ^ false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6540
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6541
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6542
!UnixOperatingSystem class methodsFor:'misc'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6543
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6544
closePid:pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6545
    "free pid resource"
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6546
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6547
    ^ true.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6548
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6549
    "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
  6550
    "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
  6551
    "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
  6552
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6553
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6554
slowFork:aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6555
    "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
  6556
     Only used internally on SYSV3 systems"
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
    SlowFork := aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6559
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6560
    "Modified: 22.4.1996 / 13:13:09 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6561
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6562
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6563
!UnixOperatingSystem class methodsFor:'os queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6564
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6565
executableFileExtensions
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6566
    "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
  6567
     Only req'd for msdos like systems ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6568
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6569
    ^ #('')
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6570
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6571
    "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
  6572
    "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
  6573
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6574
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6575
getDomainName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6576
    "return the domain this host is in.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6577
     Notice:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6578
	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
  6579
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6580
    |name idx hostName|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6581
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6582
    DomainName notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6583
	^ DomainName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6584
    ].
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6585
    name := self primGetDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6586
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6587
	"/ fallBack
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6588
	name := self getEnvironment:'DOMAIN'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6589
	name isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6590
	    name := self getCommandOutputFrom:'domainname'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6591
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6592
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6593
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6594
	"/ sometimes, we can extract the domainName from the hostName ...
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6595
	hostName := self primGetHostName.
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6596
	hostName notNil ifTrue:[
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6597
	    (hostName occurrencesOf:$.) == 1 ifTrue:[
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6598
		idx := hostName indexOf:$..
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6599
		idx ~~ 0 ifTrue:[
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6600
		    name := hostName copyFrom:idx+1.
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6601
		]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6602
	    ]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6603
	]. 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6604
	name isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6605
	    'UnixOperatingSystem [warning]: cannot find out domainname' errorPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6606
	    name := 'unknown'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6607
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6608
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6609
    DomainName := name.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6610
    ^ name
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6611
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6612
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6613
     OperatingSystem getDomainName
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6614
     OperatingSystem getHostName
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6615
     OperatingSystem primGetHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6616
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6617
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6618
    "Modified: 26.4.1996 / 10:04:54 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6619
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6620
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6621
getEnvironment:aStringOrSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6622
    "get an environment string"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6623
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6624
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6625
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6626
    char *env;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6627
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6628
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6629
    if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6630
	env =  getenv(__stringVal(aStringOrSymbol));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6631
	if (env) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6632
	    RETURN ( __MKSTRING(env) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6633
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6634
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6635
    }
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6636
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  6637
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6638
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6639
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6640
     OperatingSystem getEnvironment:'LANG'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6641
     OperatingSystem getEnvironment:'LOGIN'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6642
     OperatingSystem getEnvironment:'HOME'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6643
     OperatingSystem getEnvironment:'NNTPSERVER'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6644
     OperatingSystem getEnvironment:'MAIL'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6645
     OperatingSystem getEnvironment:'PATH'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6646
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6647
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6648
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6649
getHostName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6650
    "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
  6651
     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
  6652
     Notice:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6653
	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
  6654
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6655
    |name idx|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6656
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6657
    HostName notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6658
	^ HostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6659
    ].
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6660
    name := self primGetHostName.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6661
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6662
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6663
	"/ fallBack
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6664
	name := self getEnvironment:'HOST'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6665
	name isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6666
	    name := self getCommandOutputFrom:'hostname'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6667
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6668
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6669
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6670
	'UnixOperatingSystem [warning]: cannot find out hostname' errorPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6671
	name := 'unknown'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6672
    ] ifFalse:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6673
	"/ on some systems, the hostname already contains the domain.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6674
	"/ decompose it here.
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6675
	(name occurrencesOf:$.) == 1 ifTrue:[
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6676
	    idx := name indexOf:$..
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6677
	    idx ~~ 0 ifTrue:[
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6678
		DomainName := name copyFrom:(idx+1).
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6679
		name := name copyTo:(idx-1).
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6680
	    ]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6681
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6682
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6683
    HostName := name.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6684
    ^ name
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6685
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6686
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6687
     OperatingSystem getHostName
3496
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6690
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6691
getLocaleInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6692
    "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
  6693
     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
  6694
     Possible fields are:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6695
	decimalPoint                    <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6696
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6697
	thousandsSep                    <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6698
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6699
	internationalCurrencySymbol     <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6700
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6701
	currencySymbol                  <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6702
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6703
	monetaryDecimalPoint            <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6704
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6705
	monetaryThousandsSeparator      <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6706
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6707
	positiveSign                    <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6708
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6709
	negativeSign                    <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6710
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6711
	internationalFractionalDigits   <Integer>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6712
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6713
	fractionalDigits                <Integer>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6714
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6715
	positiveSignPrecedesCurrencySymbol      <Boolean>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6716
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6717
	negativeSignPrecedesCurrencySymbol      <Boolean>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6718
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6719
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6720
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6721
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6722
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6723
	positiveSignPosition                            <Symbol>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6724
							one of: #parenthesesAround, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6725
								#signPrecedes, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6726
								#signSuceeds, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6727
								#signPrecedesCurrencySymbol,
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6728
								#signSuceedsCurrencySymbol
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6729
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6730
	negativeSignPosition                            <like above>
3496
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
     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
  6733
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6734
     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
  6735
     it should be used by applications as required.
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6738
    |info val|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6739
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6740
    LocaleInfo notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6741
	"/ return the internal info; useful on systems which do not
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6742
	"/ support this.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6743
	^ LocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6744
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6745
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6746
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6747
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6748
    char *decimalPoint;         /* something like "." (US) or "," (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6749
    char *thousandsSep;         /* something like "," (US) or "." (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6750
    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
  6751
    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
  6752
    char *monDecimalPoint;      /* money: decimal point */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6753
    char *monThousandsSep;      /* money: thousands sep */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6754
    char *positiveSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6755
    char *negativeSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6756
    int   intFractDigits;       /* money: international digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6757
    int   fractDigits;          /* money: local digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6758
    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
  6759
    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
  6760
    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
  6761
    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
  6762
    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
  6763
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6764
				/*        2: sign succeeds the value & currency symbol */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6765
				/*        3: sign immediately precedes the currency symbol */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6766
				/*        4: sign immediately suceeds the currency symbol */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6767
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6768
#if defined(HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6769
    struct lconv *conf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6770
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6771
    conf = localeconv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6772
    if (conf) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6773
	decimalPoint = conf->decimal_point;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6774
	thousandsSep = conf->thousands_sep;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6775
	intCurrencySymbol = conf->int_curr_symbol;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6776
	currencySymbol = conf->currency_symbol;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6777
	monDecimalPoint = conf->mon_decimal_point;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6778
	monThousandsSep = conf->mon_thousands_sep;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6779
	positiveSign = conf->positive_sign;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6780
	negativeSign = conf->negative_sign;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6781
	intFractDigits = conf->int_frac_digits;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6782
	fractDigits = conf->frac_digits;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6783
	csPosPrecedes = conf->p_cs_precedes; 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6784
	csNegPrecedes = conf->n_cs_precedes; 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6785
	csPosSepBySpace = conf->p_sep_by_space; 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6786
	csNegSepBySpace = conf->n_sep_by_space; 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6787
	csPosSignPosition = conf->p_sign_posn;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6788
	csNegSignPosition = conf->n_sign_posn;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6789
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6790
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6791
    decimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6792
    thousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6793
    intCurrencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6794
    currencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6795
    monDecimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6796
    monThousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6797
    positiveSign =  (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6798
    negativeSign =(char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6799
    intFractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6800
    fractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6801
    csPosPrecedes = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6802
    csNegPrecedes = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6803
    csPosSepBySpace = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6804
    csNegSepBySpace = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6805
    csPosSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6806
    csNegSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6807
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6808
    if (decimalPoint) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6809
	val = __MKSTRING(decimalPoint);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6810
	__AT_PUT_(info, @symbol(decimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6811
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6812
    if (thousandsSep) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6813
	val = __MKSTRING(thousandsSep);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6814
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6815
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6816
    if (intCurrencySymbol) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6817
	val = __MKSTRING(intCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6818
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6819
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6820
    if (currencySymbol) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6821
	val = __MKSTRING(currencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6822
	__AT_PUT_(info, @symbol(currencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6823
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6824
    if (monDecimalPoint) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6825
	val = __MKSTRING(monDecimalPoint);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6826
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6827
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6828
    if (monThousandsSep) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6829
	val = __MKSTRING(monThousandsSep);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6830
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6831
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6832
    if (positiveSign) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6833
	val = __MKSTRING(positiveSign);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6834
	__AT_PUT_(info, @symbol(positiveSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6835
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6836
    if (negativeSign) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6837
	val = __MKSTRING(negativeSign);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6838
	__AT_PUT_(info, @symbol(negativeSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6839
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6840
    if (intFractDigits >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6841
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __MKSMALLINT(intFractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6842
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6843
    if (fractDigits >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6844
	__AT_PUT_(info, @symbol(fractionalDigits),  __MKSMALLINT(fractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6845
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6846
    if (csPosPrecedes >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6847
	if (csPosPrecedes == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6848
	    val = false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6849
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6850
	    val = true;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6851
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6852
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6853
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6854
    if (csNegPrecedes >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6855
	if (csNegPrecedes == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6856
	    val = false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6857
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6858
	    val = true;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6859
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6860
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6861
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6862
    if (csPosSepBySpace >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6863
	if (csPosSepBySpace == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6864
	    val = false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6865
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6866
	    val = true;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6867
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6868
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6869
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6870
    if (csNegSepBySpace >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6871
	if (csNegSepBySpace == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6872
	    val = false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6873
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6874
	    val = true;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6875
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6876
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6877
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6878
    switch (csPosSignPosition) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6879
	case 0:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6880
	    val = @symbol(parenthesesAround);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6881
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6882
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6883
	case 1:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6884
	    val = @symbol(signPrecedes);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6885
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6886
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6887
	case 2:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6888
	    val = @symbol(signSuceeds);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6889
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6890
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6891
	case 3:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6892
	    val = @symbol(signPrecedesCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6893
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6894
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6895
	case 4:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6896
	    val = @symbol(signSuceedsCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6897
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6898
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6899
	default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6900
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6901
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6902
    if (val != nil) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6903
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6904
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6905
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6906
    switch (csNegSignPosition) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6907
	case 0:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6908
	    val = @symbol(parenthesesAround);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6909
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6910
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6911
	case 1:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6912
	    val = @symbol(signPrecedes);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6913
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6914
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6915
	case 2:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6916
	    val = @symbol(signSuceeds);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6917
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6918
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6919
	case 3:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6920
	    val = @symbol(signPrecedesCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6921
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6922
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6923
	case 4:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6924
	    val = @symbol(signSuceedsCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6925
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6926
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6927
	default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6928
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6929
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6930
    if (val != nil) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6931
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6932
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6933
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6934
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6935
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6936
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6937
     OperatingSystem getLocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6938
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6939
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6940
    "Created: 23.12.1995 / 14:19:20 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6941
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6942
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6943
getNetworkMACAdresses
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  6944
    "return a dictionary filled with 
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  6945
	key -> name of interface 
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  6946
        value -> the MAC adress (as ByteArray)
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  6947
     for each interface 
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  6948
    "
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6949
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6950
    | arrayOfAdresses arrayOfNames noOfMaxIf noOfIf retDictionary count
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6951
      name address idx1 idx2 ok|
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6952
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6953
    noOfIf := 0.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6954
    noOfMaxIf := 50.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6955
    arrayOfAdresses := ByteArray new:(6 * noOfMaxIf). "/ 20 interfaces allowed 6bytes per interface
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6956
    arrayOfNames := ByteArray new:(16 * noOfMaxIf).
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6957
    ok := false.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6958
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6959
%{
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6960
#ifdef NET_IF_SUPPORT
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6961
    typedef struct ifNames{
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6962
	char nameIf[IFNAMSIZ];
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6963
    } ifNames;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6964
    typedef struct ifAdresses{
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6965
	char hwdAdress[IFHWADDRLEN];
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6966
    } ifAdresses;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6967
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6968
    ifNames namesOfIf[50];
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6969
    ifAdresses adressesOfIf[50];
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6970
    int    afinet_socket;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6971
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6972
    struct ifconf           ifc;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6973
    struct ifreq            *ifr, *last_ifr;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6974
    struct ifreq            ifreq;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6975
    unsigned char           buf[1024]; 
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6976
    int                     n_ifs, i, countOfIf; 
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6977
    int                     prev_size = sizeof(struct ifreq); 
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6978
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6979
//    char * this_ifc_name;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6980
//    int this_ifc_flags;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6981
    int this_ifc_hashwaddr;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6982
    char this_ifc_hwaddr[6];
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6983
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6984
    //
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6985
    // Open an INET socket
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6986
    //
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6987
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6988
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6989
    if (afinet_socket < 0)
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6990
    {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6991
	fprintf (stderr, "Cant open socket\n");
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  6992
	goto bad;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6993
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6994
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6995
    //
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6996
    // Get the list of network interfaces
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6997
    //
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6998
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6999
    ifc.ifc_len = sizeof (buf);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7000
    ifc.ifc_buf = (caddr_t) buf;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7001
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7002
    if (ioctl (afinet_socket, (int) SIOCGIFCONF, (caddr_t) &ifc) < 0)
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7003
    {                                                 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7004
	fprintf (stderr, "ioctl(SIOCGIFCONF) failed\n");
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7005
	close(afinet_socket);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7006
	goto bad;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7007
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7008
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7009
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7010
    if (n_ifs > 50) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7011
	 n_ifs = 50;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7012
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7013
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7014
    last_ifr = (struct ifreq *) (ifc.ifc_buf + (n_ifs * sizeof (struct ifreq))); 
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7015
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7016
    //
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7017
    // Iterate of the list of the system's netif. Find all
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7018
    // active interface and his Ethernet address ; use it.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7019
    //
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7020
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7021
    memset(namesOfIf, 0, sizeof(namesOfIf));
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7022
    memset(adressesOfIf, 0, sizeof(adressesOfIf));
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7023
    countOfIf = 0;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7024
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7025
    for (i=0, ifr = ifc.ifc_req; 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7026
	 (ifr < last_ifr);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7027
	 i++, ifr = (struct ifreq *)(( (char *) ifr ) + prev_size))          
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7028
    {
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7029
//        this_ifc_name = ifr->ifr_ifrn.ifrn_name;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7030
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7031
	//
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7032
	// Get Flags for this interface
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7033
	//
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7034
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7035
	memcpy(&ifreq, ifr, sizeof(ifreq)); 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7036
	if (ioctl (afinet_socket,  SIOCGIFFLAGS, &ifreq) < 0)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7037
	{
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7038
	    fprintf(stderr, "Error ioctl(SIOCGIFFLAGS)\n");
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7039
	} 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7040
	else 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7041
	{
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7042
//            this_ifc_flags = ifreq.ifr_ifru.ifru_flags;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7043
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7044
	    //
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7045
	    // Get Hardware address for this interface
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7046
	    //
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7047
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7048
	    memcpy(&ifreq, ifr, sizeof(ifreq)); 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7049
	    this_ifc_hashwaddr = 1;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7050
	    if (ioctl (afinet_socket,  SIOCGIFHWADDR, &ifreq) < 0)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7051
	    {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7052
		this_ifc_hashwaddr = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7053
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7054
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7055
	    if (this_ifc_hashwaddr)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7056
	    {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7057
		memcpy(adressesOfIf[i].hwdAdress, &ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7058
		memcpy(namesOfIf[i].nameIf, &ifreq.ifr_ifrn.ifrn_name, IFNAMSIZ);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7059
		countOfIf += 1;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7060
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7061
	}
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7062
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7063
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7064
    close(afinet_socket);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7065
    arrayOfAdresses = __MKBYTEARRAY(adressesOfIf, IFHWADDRLEN * 20);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7066
    arrayOfNames = __MKBYTEARRAY(namesOfIf, IFNAMSIZ * 20);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7067
    noOfIf = __mkSmallInteger(countOfIf);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7068
    ok = true;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7069
bad: ;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7070
#endif /* NET_IF_SUPPORT */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7071
%}.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7072
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7073
    ok ifFalse:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7074
	self primitiveFailed.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7075
	^  nil
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7076
    ].
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7077
    retDictionary := Dictionary new.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7078
    count := 1.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7079
    [count <= noOfIf] whileTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7080
	idx1 := (count-1) * 16 + 1.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7081
	idx2 := idx1 + 16 - 1.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7082
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7083
	name := arrayOfNames copyFrom:idx1 to:idx2.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7084
	(name indexOf:0) ~~ 0 ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7085
	    name := name copyTo:(name indexOf:0)-1.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7086
	].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7087
	name := name asString.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7088
	idx1 := (count-1)*6 + 1.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7089
	idx2 := idx1 + 6 - 1.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7090
	address := (arrayOfAdresses copyFrom:idx1 to:idx2).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7091
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7092
	retDictionary at:name put:address.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7093
	count := count + 1.        
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7094
    ].
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7095
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7096
    ^ retDictionary
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7097
!
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7098
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7099
getNetworkMACAdressesForIf:ifName
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  7100
    "return the MAC adress (6-byte byteArray) for interface ifName
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  7101
    "
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7102
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7103
    ^ self getNetworkMACAdresses at:ifName.
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7104
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  7105
    "
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  7106
     OperatingSystem getNetworkMACAdressesForIf:'eth0'
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  7107
    "
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7108
!
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7109
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7110
getProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7111
    "return the (unix-)processId"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7112
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7113
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7115
    int pid = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7116
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7117
    pid = getpid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7118
    RETURN ( __MKSMALLINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7119
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7120
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7121
     OperatingSystem getProcessId
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7122
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7123
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7124
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7125
getSystemID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7126
    "if supported by the OS, return the systemID;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7127
     a unique per machine identification.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7128
     WARNING:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7129
	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
  7130
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7131
%{  /* NO_CONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7132
#if defined(IRIX5) && !defined(HAS_GETHOSTID)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7133
    char idBuffer[MAXSYSIDSIZE];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7134
    int retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7135
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7136
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7137
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7138
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7139
	bcopy(idBuffer, __byteArrayVal(arr), MAXSYSIDSIZE);
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7140
	RETURN (arr);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7141
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7142
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7143
#if defined(HAS_GETHOSTID)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7144
    int runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7145
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7146
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7147
    runningId = gethostid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7148
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7149
    *(int *)(__byteArrayVal(arr)) = runningId;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7150
    RETURN (arr);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7151
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7152
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7153
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7154
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7155
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7156
	buffer[0] = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7157
	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7158
	    buffer[127] = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7159
	    if (strlen(buffer) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7160
		RETURN(__MKSTRING(buffer));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7161
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7162
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7163
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7164
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7165
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7166
    ^ 'unknown'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7167
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7168
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7169
     OperatingSystem getSystemID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7170
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7171
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7172
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7173
getSystemInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7174
    "return info on the system weare running on.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7175
     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
  7176
     otherwise, some simulated info is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7177
 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7178
     WARNING:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7179
       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
  7180
       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
  7181
       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
  7182
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7183
       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
  7184
       information. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7185
       (in case of system/version specific OS errors, conditional workarounds and patches
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7186
	may be based upon this info).
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7187
       Also, applications could enable/disable buffering or otherwise reduce
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7188
       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
  7189
       Your application may make use of available information for tuning,
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7190
       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
  7191
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7192
     The returned info may (or may not) contain:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7193
	#system -> some operating system identification (irix, Linux, nt, win32s ...) 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7194
	#version -> OS version (some os version identification)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7195
	#release -> OS release (3.5, 1.2.1 ...)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7196
	#node   -> some host identification (hostname)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7197
	#domain  -> domain name (hosts domain)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7198
	#machine -> type of CPU (i586, mips ...)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7199
     
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7200
     those are currently returned on some machines (no warranty)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7201
     linux:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7202
	#totalRam         -> total amount of memory available
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7203
	#sharedRam        -> amount of memory which is shared among processes
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7204
			     (i.e. shared code)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7205
	#bufferRam        -> amount used for buffers
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7206
	#swapSize         -> total size of swap space
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7207
	#freeSwap         -> free amount in swapSpace
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7208
	#extendedInstructions -> extended instruction set info
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7209
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7210
     osf:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7211
	#physicalRam      -> total amount of physical memory
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7212
	#cpuType          -> type of cpu (more detailed than machine)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7213
	#numberOfCPUs     -> number of cpus in box
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7214
        
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7215
     solaris:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7216
	#physicalRam      -> total amount of physical memory
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7217
	#availableRam     -> total available amount of physical memory (i.e. unused ram)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7218
	#freeRam          -> amount of free memory
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7219
	#numberOfCPUs     -> number of cpus in box (online CPUS)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7220
	[#dCacheSize]     -> bytes in data cache (only available on some solaris versions)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7221
	[#iCacheSize]     -> bytes in data cache (only available on some solaris versions)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7222
	[#instructionSets]-> instruction sets available (only available on some solaris versions)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7223
	[#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
  7224
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7225
     hpux:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7226
	#physicalRam      -> total amount of physical memory in box
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7227
	#activeRealMemory -> ? - read pstat documentation
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7228
	#activeVirtualRam -> ? - read pstat documentation
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7229
	#freeMemory       -> ? - read pstat documentation
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7230
	#realMemory       -> ? (amount of memory left to user programs)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7231
	#virtualRam       -> ? - read pstat documentation
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7232
    "
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7233
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7234
    |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
  7235
     physicalRam availableRam totalRam sharedRam bufferRam swapSize freeSwap
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7236
     numberOfCPUs pageSize physicalPages availablePages dCacheSize iCacheSize
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7237
     virtualRam activeVirtualRam realMemory activeRealMemory freeMemory
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7238
     instructionSets extendedInstructions platform|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7240
%{  /* STACK: 4096 */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7241
#ifdef LINUX
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  7242
# 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
  7243
    /* 
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7244
     * additional info available ...
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7245
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7246
    struct sysinfo infoBuffer;
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7247
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7248
    if (sysinfo(&infoBuffer) >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7249
	totalRam   = __MKUINT(infoBuffer.totalram);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7250
	sharedRam = __MKUINT(infoBuffer.sharedram);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7251
	bufferRam = __MKUINT(infoBuffer.bufferram);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7252
	swapSize  = __MKUINT(infoBuffer.totalswap);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7253
	freeSwap  = __MKUINT(infoBuffer.freeswap);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7254
    }
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  7255
# endif
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7256
#endif /* LINUX */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7257
4088
622551d3c0d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  7258
#if defined(hpux) && !defined(__GNUC__)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7259
# include <sys/pstat.h>
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7260
    struct pst_static stat_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7261
    struct pst_dynamic dynam_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7262
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7263
    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
  7264
    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
  7265
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7266
    physicalRam        = __MKUINT(stat_buf.physical_memory/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7267
    virtualRam         = __MKUINT(dynam_buf.psd_vm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7268
    activeVirtualRam   = __MKUINT(dynam_buf.psd_avm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7269
    realMemory         = __MKUINT(dynam_buf.psd_rm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7270
    activeRealMemory   = __MKUINT(dynam_buf.psd_arm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7271
    freeMemory         = __MKUINT(dynam_buf.psd_free/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7272
#endif
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7273
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7274
#if defined(HAS_UNAME)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7275
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7276
	struct utsname ubuff;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7277
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7278
	if (uname(&ubuff) >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7279
	    sys  = __MKSTRING(ubuff.sysname);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7280
	    node = __MKSTRING(ubuff.nodename);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7281
	    rel  = __MKSTRING(ubuff.release);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7282
	    ver  = __MKSTRING(ubuff.version);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7283
	    mach = __MKSTRING(ubuff.machine);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7284
# ifdef HAS_UTS_DOMAINNAME
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7285
	    dom  = __MKSTRING(ubuff.domainname);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7286
# endif /* no HAS_UTS_DOMAINNAME */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7287
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7288
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7289
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7290
#else /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7291
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7292
    /*
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7293
     * use fallBack code below
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7294
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7295
#endif /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7296
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7297
#if defined(HAS_SYSINFO)
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7298
# if defined(SI_ARCHITECTURE)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7299
    if (arch == nil) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7300
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7301
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7302
	if (sysinfo(SI_ARCHITECTURE, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7303
	    arch = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7304
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7305
    }
4923
1cacdcfc82c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4922
diff changeset
  7306
# endif /* SI_ARCHITECTURE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7307
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7308
# if defined(SI_ISALIST)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7309
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7310
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7311
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7312
	if (sysinfo(SI_ISALIST, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7313
	    instructionSets = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7314
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7315
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7316
# endif /* SI_ISALIST */
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7317
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7318
# if defined(SI_PLATFORM)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7319
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7320
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7321
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7322
	if (sysinfo(SI_PLATFORM, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7323
	    platform = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7324
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7325
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7326
# endif /* SI_PLATFORM */
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7327
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7328
# if defined(SI_RELEASE)
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7329
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7330
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7331
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7332
	if (sysinfo(SI_RELEASE, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7333
	    rel = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7334
	}
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7335
    }
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7336
# endif /* SI_RELEASE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7337
#endif /* HAS_SYSINFO */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7338
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7339
#if defined(HAS_GETDOMAINNAME)
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7340
    if (dom == nil) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7341
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7342
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7343
	if (getdomainname(buffer, sizeof(buffer)) == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7344
	    dom = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7345
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7346
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7347
#endif /* HAS_GETDOMAINNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7348
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7349
#if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7350
# ifdef _SC_NPROCESSORS_ONLN
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7351
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7352
	long val;
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7353
 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7354
	val = sysconf(_SC_NPROCESSORS_ONLN);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7355
	if (val > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7356
	    numberOfCPUs = __MKINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7357
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7358
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7359
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7360
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7361
# if defined(_SC_PAGESIZE)
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7362
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7363
	long val;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7364
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7365
	val = sysconf(_SC_PAGESIZE);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7366
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7367
	    pageSize = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7368
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7369
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7370
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7371
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7372
# if defined(_SC_PHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7373
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7374
	long val;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7375
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7376
	val = sysconf(_SC_PHYS_PAGES);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7377
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7378
	    physicalPages = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7379
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7380
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7381
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7382
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7383
# if defined(_SC_AVPHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7384
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7385
	long val;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7386
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7387
	val = sysconf(_SC_AVPHYS_PAGES);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7388
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7389
	    availablePages = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7390
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7391
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7392
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7393
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7394
# if defined(_SC_ICACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7395
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7396
	long val;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7397
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7398
	val = sysconf(_SC_ICACHE_SZ);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7399
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7400
	    iCacheSize = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7401
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7402
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7403
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7404
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7405
# if defined(_SC_DCACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7406
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7407
	long val;
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7408
 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7409
	val = sysconf(_SC_DCACHE_SZ);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7410
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7411
	    dCacheSize = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7412
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7413
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7414
# endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7415
#endif /* HAS_SYSCONF */
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7416
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7417
#if defined(HAS_GETSYSINFO)
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7418
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7419
	INT index;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7420
	int retInt32 = 0;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7421
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7422
# if defined(GSI_CPU)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7423
	index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7424
	if (getsysinfo(GSI_CPU, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7425
	    switch (retInt32) {
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7426
#  ifdef VAX_780
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7427
		case VAX_780:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7428
		    cpuType = __MKSTRING("VAX_780");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7429
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7430
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7431
#  ifdef VAX_750
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7432
		case VAX_750:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7433
		    cpuType = __MKSTRING("VAX_750");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7434
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7435
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7436
#  ifdef VAX_730
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7437
		case VAX_730:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7438
		    cpuType = __MKSTRING("VAX_730");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7439
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7440
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7441
#  ifdef VAX_8600
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7442
		case VAX_8600:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7443
		    cpuType = __MKSTRING("VAX_8600");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7444
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7445
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7446
#  ifdef VAX_8200
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7447
		case VAX_8200:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7448
		    cpuType = __MKSTRING("VAX_8200");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7449
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7450
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7451
#  ifdef VAX_8800
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7452
		case VAX_8800:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7453
		    cpuType = __MKSTRING("VAX_8800");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7454
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7455
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7456
#  ifdef MVAX_I
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7457
		case MVAX_I:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7458
		    cpuType = __MKSTRING("MVAX_I");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7459
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7460
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7461
#  ifdef MVAX_II
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7462
		case MVAX_II:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7463
		    cpuType = __MKSTRING("MVAX_II");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7464
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7465
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7466
#  ifdef V_VAX
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7467
		case V_VAX:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7468
		    cpuType = __MKSTRING("V_VAX");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7469
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7470
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7471
#  ifdef VAX_3600
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7472
		case VAX_3600:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7473
		    cpuType = __MKSTRING("VAX_3600");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7474
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7475
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7476
#  ifdef VAX_6200
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7477
		case VAX_6200:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7478
		    cpuType = __MKSTRING("VAX_6200");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7479
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7480
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7481
#  ifdef VAX_3400
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7482
		case VAX_3400:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7483
		    cpuType = __MKSTRING("VAX_3400");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7484
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7485
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7486
#  ifdef C_VAXSTAR
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7487
		case C_VAXSTAR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7488
		    cpuType = __MKSTRING("C_VAXSTAR");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7489
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7490
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7491
#  ifdef VAX_60
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7492
		case VAX_60:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7493
		    cpuType = __MKSTRING("VAX_60");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7494
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7495
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7496
#  ifdef VAX_3900
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7497
		case VAX_3900:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7498
		    cpuType = __MKSTRING("VAX_3900");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7499
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7500
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7501
#  ifdef DS_3100
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7502
		case DS_3100:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7503
		    cpuType = __MKSTRING("DS_3100");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7504
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7505
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7506
#  ifdef VAX_8820
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7507
		case VAX_8820:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7508
		    cpuType = __MKSTRING("VAX_8820");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7509
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7510
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7511
#  ifdef DS_5400
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7512
		case DS_5400:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7513
		    cpuType = __MKSTRING("DS_5400");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7514
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7515
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7516
#  ifdef DS_5800
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7517
		case DS_5800:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7518
		    cpuType = __MKSTRING("DS_5800");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7519
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7520
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7521
#  ifdef DS_5000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7522
		case DS_5000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7523
		    cpuType = __MKSTRING("DS_5000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7524
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7525
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7526
#  ifdef DS_CMAX
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7527
		case DS_CMAX:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7528
		    cpuType = __MKSTRING("DS_CMAX");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7529
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7530
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7531
#  ifdef VAX_6400
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7532
		case VAX_6400:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7533
		    cpuType = __MKSTRING("VAX_6400");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7534
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7535
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7536
#  ifdef VAXSTAR
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7537
		case VAXSTAR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7538
		    cpuType = __MKSTRING("VAXSTAR");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7539
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7540
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7541
#  ifdef DS_5500
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7542
		case DS_5500:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7543
		    cpuType = __MKSTRING("DS_5500");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7544
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7545
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7546
#  ifdef DS_5100
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7547
		case DS_5100:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7548
		    cpuType = __MKSTRING("DS_5100");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7549
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7550
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7551
#  ifdef VAX_9000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7552
		case VAX_9000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7553
		    cpuType = __MKSTRING("VAX_9000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7554
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7555
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7556
#  ifdef DS_500_100
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7557
		case DS_500_100:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7558
		    cpuType = __MKSTRING("DS_500_100");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7559
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7560
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7561
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7562
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7563
#  ifdef ALPHA_ADU
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7564
		case ALPHA_ADU:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7565
		    cpuType = __MKSTRING("ALPHA_ADU");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7566
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7567
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7568
#  ifdef DEC_4000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7569
		case DEC_4000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7570
		    cpuType = __MKSTRING("DEC_4000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7571
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7572
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7573
#  ifdef DEC_3000_500
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7574
		case DEC_3000_500:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7575
		    cpuType = __MKSTRING("DEC_3000_500");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7576
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7577
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7578
#  ifdef DEC_7000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7579
		case DEC_7000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7580
		    cpuType = __MKSTRING("DEC_7000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7581
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7582
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7583
#  ifdef DS_5000_300
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7584
		case DS_5000_300:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7585
		    cpuType = __MKSTRING("DS_5000_300");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7586
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7587
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7588
#  ifdef DEC_3000_300
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7589
		case DEC_3000_300:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7590
		    cpuType = __MKSTRING("DEC_3000_300");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7591
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7592
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7593
#  ifdef DEC_2000_300
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7594
		case DEC_2000_300:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7595
		    cpuType = __MKSTRING("DEC_2000_300");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7596
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7597
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7598
#  ifdef DEC_2100_A500
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7599
		case DEC_2100_A500:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7600
		    cpuType = __MKSTRING("DEC_2100_A500");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7601
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7602
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7603
#  ifdef DEC_2100_A50
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7604
		case DEC_2100_A50:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7605
		    cpuType = __MKSTRING("DEC_2100_A50");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7606
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7607
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7608
#  ifdef ALPHA_KN20AA
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7609
		case ALPHA_KN20AA:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7610
		    cpuType = __MKSTRING("ALPHA_KN20AA");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7611
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7612
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7613
#  ifdef DEC_21000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7614
		case DEC_21000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7615
		    cpuType = __MKSTRING("DEC_21000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7616
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7617
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7618
#  ifdef DEC_AXPVME_64
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7619
		case DEC_AXPVME_64:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7620
		    cpuType = __MKSTRING("DEC_AXPVME_64");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7621
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7622
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7623
#  ifdef DEC_2100_C500
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7624
		case DEC_2100_C500:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7625
		    cpuType = __MKSTRING("DEC_2100_C500");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7626
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7627
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7628
#  ifdef DEC_AXPPCI_33
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7629
		case DEC_AXPPCI_33:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7630
		    cpuType = __MKSTRING("DEC_AXPPCI_33");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7631
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7632
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7633
#  ifdef DEC_1000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7634
		case DEC_1000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7635
		    cpuType = __MKSTRING("DEC_1000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7636
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7637
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7638
#  ifdef EB64_PLUS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7639
		case EB64_PLUS:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7640
		    cpuType = __MKSTRING("EB64_PLUS");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7641
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7642
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7643
#  ifdef LCA_EB66
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7644
		case LCA_EB66:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7645
		    cpuType = __MKSTRING("LCA_EB66");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7646
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7647
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7648
#  ifdef ALPHA_EB164
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7649
		case ALPHA_EB164:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7650
		    cpuType = __MKSTRING("ALPHA_EB164");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7651
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7652
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7653
#  ifdef DEC_EV45_PBP
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7654
		case DEC_EV45_PBP:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7655
		    cpuType = __MKSTRING("DEC_EV45_PBP");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7656
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7657
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7658
#  ifdef DEC_1000A
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7659
		case DEC_1000A:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7660
		    cpuType = __MKSTRING("DEC_1000A");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7661
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7662
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7663
#  ifdef DEC_4100
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7664
		case DEC_4100:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7665
		    cpuType = __MKSTRING("DEC_4100");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7666
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7667
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7668
#  ifdef DEC_ALPHAVME_224
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7669
		case DEC_ALPHAVME_224:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7670
		    cpuType = __MKSTRING("DEC_ALPHAVME_224");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7671
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7672
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7673
#  ifdef DEC_1000_5
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7674
		case DEC_1000_5:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7675
		    cpuType = __MKSTRING("DEC_1000_5");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7676
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7677
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7678
#  ifdef DEC_1000A_5
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7679
		case DEC_1000A_5:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7680
		    cpuType = __MKSTRING("DEC_1000A_5");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7681
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7682
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7683
#  ifdef DEC_EV56_PBP
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7684
		case DEC_EV56_PBP:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7685
		    cpuType = __MKSTRING("DEC_EV56_PBP");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7686
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7687
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7688
#  ifdef ALPHABOOK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7689
		case ALPHABOOK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7690
		    cpuType = __MKSTRING("ALPHABOOK");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7691
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7692
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7693
#  ifdef DEC_ALPHAVME_320
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7694
		case DEC_ALPHAVME_320:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7695
		    cpuType = __MKSTRING("DEC_ALPHAVME_320");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7696
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7697
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7698
#  ifdef DEC_550
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7699
		case DEC_550:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7700
		    cpuType = __MKSTRING("DEC_550");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7701
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7702
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7703
#  ifdef DEC_6600
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7704
		case DEC_6600:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7705
		    cpuType = __MKSTRING("DEC_6600");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7706
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7707
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7708
#  ifdef UNKN_SYSTEM
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7709
		case UNKN_SYSTEM:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7710
		    cpuType = __MKSTRING("UNKN_SYSTEM");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7711
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7712
#  endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7713
		default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7714
		    cpuType = __MKSTRING("OTHER_DEC_SYSTEM");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7715
		    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7716
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7717
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7718
# endif /* GSI_CPU */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7719
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7720
# if defined(GSI_CPU_INFO)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7721
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7722
	 * stupid: OSF1 pre V4.0 has no mhz, but V4.0 has it.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7723
	 * use the GSI_PLATFORM_NAME as a hint - it is only defined in
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7724
	 * V4.0 and higher ... (sigh)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7725
	 */
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7726
#  if defined GSI_PLATFORM_NAME
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7727
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7728
	    struct cpu_info cpuInfo;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7729
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7730
	    index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7731
	    if (getsysinfo(GSI_CPU_INFO, &cpuInfo, sizeof(cpuInfo), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7732
		cpuSpeed   = __MKUINT(cpuInfo.mhz);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7733
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7734
	}
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7735
#  endif
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7736
# endif /* GSI_CPU_INFO */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7737
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7738
# if defined(GSI_CPUS_IN_BOX)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7739
	index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7740
	if (getsysinfo(GSI_CPUS_IN_BOX, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7741
	    numberOfCPUs   = __MKUINT(retInt32);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7742
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7743
# endif /* GSI_CPUS_IN_BOX */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7744
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7745
# if defined(GSI_PHYSMEM)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7746
	index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7747
	if (getsysinfo(GSI_PHYSMEM, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7748
	    INT bytes = retInt32 * 1024;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7749
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7750
	    physicalRam   = __MKUINT(bytes);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7751
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7752
# endif /* GSI_PHYSMEM */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7753
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7754
# if defined(GSI_PLATFORM_NAME) && (!defined(HAS_SYSINFO) || !defined(SI_PLATFORM))
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7755
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7756
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7757
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7758
	index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7759
	if (getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7760
	    platform = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7761
	}
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7762
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7763
# endif /* GSI_PLATFORM_NAME */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7764
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7765
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7766
#endif /* HAS_GETSYSINFO */
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7767
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7768
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7769
	extern OBJ __getInstructionSetInfo();
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7770
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7771
	extendedInstructions = __getInstructionSetInfo();
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7772
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7773
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7774
    sys isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7775
	sys := self getSystemType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7776
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7777
    node isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7778
	node := self getHostName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7779
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7780
    dom isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7781
	dom := self getDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7782
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7783
    mach isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7784
	mach := self getCPUType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7785
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7786
    arch isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7787
	arch := sys.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7788
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7789
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7790
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7791
    info at:#system put:sys.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7792
    info at:#node put:node.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7793
    rel notNil ifTrue:[info at:#release put:rel].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7794
    ver notNil ifTrue:[info at:#version put:ver].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7795
    mach notNil ifTrue:[info at:#machine put:mach].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7796
    arch notNil ifTrue:[info at:#architecture put:arch].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7797
    dom notNil ifTrue:[info at:#domain put:dom].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7798
    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7799
	physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7800
    ].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7801
    physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7802
    (pageSize notNil and:[availablePages notNil]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7803
	availableRam := pageSize * availablePages. "/ done here - could be largeInt.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7804
	availableRam notNil ifTrue:[info at:#availableRam put:availableRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7805
    ].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7806
    totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7807
    sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7808
    bufferRam notNil ifTrue:[info at:#bufferRam put:bufferRam].
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7809
    virtualRam notNil ifTrue:[info at:#virtualRam put:virtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7810
    activeVirtualRam notNil ifTrue:[info at:#activeVirtualRam put:activeVirtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7811
    realMemory notNil ifTrue:[info at:#realMemory put:realMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7812
    activeRealMemory notNil ifTrue:[info at:#activeRealMemory put:activeRealMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7813
    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
  7814
    swapSize notNil ifTrue:[info at:#swapSize put:swapSize].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7815
    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
  7816
    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
  7817
    cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7818
    cpuSpeed notNil ifTrue:[info at:#cpuSpeed put:cpuSpeed].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7819
    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7820
    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7821
    instructionSets notNil ifTrue:[info at:#instructionSets put:instructionSets].
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7822
    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
  7823
    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
  7824
    info at:#osType put:(self getOSType).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7825
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7826
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7827
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7828
     OperatingSystem getSystemInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7829
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7830
!
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
getSystemType
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7833
    "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
  7834
     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
  7835
     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
  7836
     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
  7837
     here ... 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7838
     (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
  7839
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7840
    |sys|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7841
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7842
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7843
#   ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7844
#    define SYS_STRING "next"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7845
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7846
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7847
#   ifdef IRIS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7848
#    define SYS_STRING "iris"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7849
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7850
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7851
#   ifdef SYS_STRING
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7852
     sys = __MKSTRING(SYS_STRING);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7853
#    undef SYS_STRING
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7854
#   endif
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
    sys isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7858
	^ self getOSType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7859
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7860
    ^ sys
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7861
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7862
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7863
     OperatingSystem getSystemType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7864
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7865
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7866
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7867
isBSDlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7868
    "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
  7869
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7870
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7871
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7872
#if defined(BSD) || defined(MACH) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7873
    RETURN ( true );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7874
#endif
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
    ^ false
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7877
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7878
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7879
     OperatingSystem isBSDlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7880
    "
3496
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
isUNIXlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7884
    "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
  7885
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7886
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7887
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7888
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7889
     OperatingSystem isUNIXlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7890
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7891
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7892
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7893
maxFileNameLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7894
    "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
  7895
     CAVEAT:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7896
	 Actually, the following is somewhat wrong - some systems
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7897
	 support different sizes, depending on the volume.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7898
	 We return a somewhat conservative number here.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7899
	 Another entry, to query for volume specific max
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7900
	 will be added in the future."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7901
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7902
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7903
 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7904
    /*
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7905
     * 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
  7906
     */
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7907
#   if defined(MAXFILENAMELEN)
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7908
      RETURN ( __MKSMALLINT(MAXFILENAMELEN) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7909
#   else
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7910
#    if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7911
      RETURN ( __MKSMALLINT(255) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7912
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7913
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7914
#    ifdef realIX
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7915
       RETURN ( __MKSMALLINT(127) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7916
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7917
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7918
#    ifdef SYSV
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7919
       RETURN ( __MKSMALLINT(14) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7920
#    endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7921
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7922
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7923
    "unix default"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7924
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7925
    ^ 14
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7926
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7927
    "
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7928
     OperatingSystem maxFileNameLength
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7929
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7930
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7931
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7932
maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7933
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7934
%{
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7935
     long l;
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7936
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7937
     l = sysconf(_SC_OPEN_MAX);
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7938
     if (l >= 0) {
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7939
         RETURN(__mkSmallInteger(l));
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7940
     }
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7941
%}.
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7942
     self primitiveFailed
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7943
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7944
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7945
      self maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7946
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7947
!
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7948
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7949
maxPathLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7950
    "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
  7951
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7952
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7953
    RETURN ( __MKSMALLINT(MAXPATHLEN) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7954
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7955
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7956
     OperatingSystem maxPathLength   
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7957
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7958
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7959
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7960
pathSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7961
    "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
  7962
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7963
    ^ $:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7964
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7965
    "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
  7966
    "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
  7967
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7968
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7969
platformName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7970
    "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
  7971
     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
  7972
     #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
  7973
     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
  7974
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7975
    ^ #unix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7976
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7977
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7978
     OperatingSystem platformName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7979
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7980
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7981
    "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
  7982
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7983
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7984
primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7985
    "return the domain this host is in.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7986
     Notice:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7987
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7988
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7989
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7990
#if defined(HAS_GETDOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7991
    char buffer[128];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7992
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7993
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7994
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7995
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7996
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7997
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7998
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7999
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8000
    if (uname(&ubuff) >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8001
	RETURN (__MKSTRING(ubuff.domainname));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8002
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8003
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8004
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8005
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8006
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8007
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8008
    if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8009
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8010
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8011
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8012
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8013
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8014
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8015
    ^ nil
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8016
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8017
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8018
     OperatingSystem primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8019
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8020
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8021
    "Modified: 26.4.1996 / 10:04:54 / stefan"
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8022
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8023
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8024
primGetHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8025
    "return the hostname we are running on - if there is
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8026
     a HOST environment variable, we are much faster here ...
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8027
     Notice:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8028
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8029
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8030
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8031
#if defined(HAS_GETHOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8032
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8033
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8034
    if (gethostname(buffer, sizeof(buffer)) == 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8035
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8036
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8037
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8038
# if defined(HAS_UNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8039
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8040
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8041
    if (uname(&ubuff) >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8042
	RETURN (__MKSTRING(ubuff.nodename));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8043
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8044
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8045
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8046
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8047
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8048
 
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8049
    if ((ret = sysinfo(SI_HOSTNAME, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8050
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8051
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8052
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8053
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8054
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8055
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8056
    ^ nil 
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8057
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8058
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8059
     OperatingSystem getHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8060
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8061
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8062
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8063
setLocaleInfo:anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8064
    "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
  8065
     (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
  8066
     See description of fields in #getLocaleInfo.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8067
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8068
     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
  8069
     it should be used by applications as required."
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
    LocaleInfo := anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8072
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8073
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8074
     |d|
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
     d := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8077
     d at:#decimalPoint                 put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8078
     d at:#thousandsSeparator           put:','         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8079
     d at:#currencySymbol               put:'USD'       .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8080
     d at:#monetaryDecimalPoint         put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8081
     d at:#monetaryThousandsSeparator   put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8082
     d at:#fractionalDigits             put:2           .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8083
     d at:#positiveSign                 put:'+'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8084
     d at:#negativeSign                 put:'-'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8085
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8086
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8087
     OperatingSystem setLocaleInfo:d
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8088
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8089
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8090
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8091
supportsChildInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8092
    "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
  8093
     through interrupts (i.e. SIGCHILD)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8094
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8095
%{  /* NOCONTEXT */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8096
#if defined(SIGCHLD) || defined(SIGCLD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8097
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8098
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8099
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8100
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8101
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8102
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8103
     OperatingSystem supportsChildInterrupts 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8104
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8105
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8106
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8107
supportsIOInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8108
    "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
  8109
     (i.e. SIGPOLL/SIGIO).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8110
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8111
     Currently, this mechanism does not work on all
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8112
     systems ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8113
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8115
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8116
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8117
  /* positive defines here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8118
   *  - irix5.2 does not work
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8119
   */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8120
#if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8121
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8122
# if defined(SIGIO) || defined(SIGPOLL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8123
#  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
  8124
#   if defined(F_SETOWN) || defined(FIOSETOWN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8125
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8126
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8127
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8128
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8129
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8130
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8131
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8132
#endif /* machines where it works */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8133
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8134
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8135
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8136
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8137
     OperatingSystem supportsIOInterrupts 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8138
    "
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8139
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8140
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8141
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8142
supportsNonBlockingIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8143
    "return true, if the OS supports nonblocking IO."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8144
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8145
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8146
#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
  8147
       RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8148
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8149
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8150
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8151
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8152
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8153
     OperatingSystem supportsNonBlockingIO  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8154
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8155
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8157
supportsSelect
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8158
    "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
  8159
     filedescriptors via select.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8160
     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
  8161
     intervals for I/O becoming ready."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8162
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8163
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8165
#if defined(sco)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8166
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8167
     * 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
  8168
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8169
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8170
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8171
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8172
    ^ true
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8175
     OperatingSystem supportsSelect 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8176
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8177
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8178
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8179
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8180
supportsSymbolicLinks
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8181
    "return true, if the OS supports symbolic (soft) links;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8182
     most UNIX'es do; many other OS's do not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8183
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8184
%{  /* NOCONTEXT */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8185
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8186
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8187
    /*
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8188
     * assume yes - if that is defined.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8189
     */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8190
    RETURN(true);
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8191
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8192
%}.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8193
    ^ false
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8194
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8195
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8196
     OperatingSystem supportsSymbolicLinks 
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8197
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8198
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8199
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8200
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8201
!UnixOperatingSystem class methodsFor:'path queries'!
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8202
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8203
defaultSystemPath
5647
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  8204
    "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
  8205
     (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
  8206
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
  8207
    |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
  8208
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  8209
    majorVersionNr := Smalltalk majorVersionNr.
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8210
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8211
    sysPath := super defaultSystemPath.
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8212
    #(
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8213
	'/usr/local/lib/smalltalk'
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8214
	'/usr/lib/smalltalk'
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8215
	'/lib/smalltalk'
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8216
	'/opt/smalltalk'
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8217
    ) do:[:d |
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8218
	(d asFilename isDirectory) ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8219
	    "/ try to guess a gnu-smalltalk; skip it
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8220
	    (d asFilename construct:'initialize.st') exists ifFalse:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8221
		releaseFile := d asFilename construct:'RELEASE'.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8222
		releaseFile exists ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8223
		    s := releaseFile readStream.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8224
		    s notNil ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8225
			v := Integer readFrom:s onError:-1.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8226
			s close.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8227
			v == majorVersionNr ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8228
			    sysPath add:d
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8229
			] ifFalse:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8230
			    ('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE mismatch)') infoPrintCR.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8231
			]
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8232
		    ] ifFalse:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8233
			('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE missing)') infoPrintCR.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8234
		    ]
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8235
		]
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8236
	    ]
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8237
	]
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8238
    ].
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8239
    ^ sysPath
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8240
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8241
    "
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8242
     OperatingSystem defaultSystemPath
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8243
    "
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8244
! !
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8245
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8246
!UnixOperatingSystem class methodsFor:'private'!
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8247
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8248
osProcessStatusClass
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8249
    ^ OSProcessStatus
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8250
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8251
    "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
  8252
! !
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8253
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8254
!UnixOperatingSystem class methodsFor:'shared memory access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8255
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8256
shmAttach:id address:addr flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8257
    "low level entry to shmat()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8258
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8259
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8260
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8261
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8262
    void *address, *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8263
    int shmflg, shmid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8264
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8265
    if (__isSmallInteger(addr)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8266
     && __bothSmallInteger(flags, id)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8267
	shmaddr = (void *) __intVal(addr);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8268
	shmflg = __intVal(flags);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8269
	shmid = __intVal(id);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8270
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8271
	address = shmat(shmid, shmaddr, shmflg);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8272
	if (address != (void *)-1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8273
	    RETURN (__MKEXTERNALBYTES(addr));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8274
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8275
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8276
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8277
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8278
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8279
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8280
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8281
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8282
    "Modified: 22.4.1996 / 13:15:12 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8283
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8284
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8285
shmDetach:addr
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8286
    "low level entry to shmdt()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8287
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8288
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8289
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8290
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8291
    void *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8292
    int rslt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8293
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8294
    if (__isSmallInteger(addr)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8295
	shmaddr = (void *) __intVal(addr);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8296
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8297
	rslt = shmdt(shmaddr);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8298
	if (rslt != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8299
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8300
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8301
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8302
	RETURN (false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8303
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8304
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8305
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8306
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8308
    "Modified: 22.4.1996 / 13:15:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8309
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8310
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8311
shmGet:key size:size flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8312
    "low level entry to shmget()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8313
     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
  8314
     - use the provided wrapper class SharedExternalBytes instead."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8315
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8316
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8317
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8318
    if (__bothSmallInteger(key, size)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8319
     && __isSmallInteger(flags)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8320
	int rslt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8321
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8322
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8323
	if (rslt != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8324
	    RETURN (__MKSMALLINT(rslt));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8325
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8326
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8327
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8328
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8329
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8330
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8331
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8332
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8333
    "Modified: 22.4.1996 / 13:14:46 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8334
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8335
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8336
!UnixOperatingSystem class methodsFor:'socket creation'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8337
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8338
socketWithDomain:domainArg type:typeArg protocol:protocolArg 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8339
    "set up socket with domain, type and protocol number.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8340
     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
  8341
     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
  8342
     #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8343
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8344
    ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8345
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8346
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8347
!UnixOperatingSystem class methodsFor:'time and date'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8348
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8349
computeDatePartsOf:osTime for:aBlock
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8350
    "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
  8351
     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
  8352
     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
  8353
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8354
    |year month day osSeconds i|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8355
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8356
    osSeconds := osTime // 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8357
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8358
    struct tm* tmPtr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8359
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8360
    TIME_T tt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8361
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8362
    t = __longIntVal(osSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8363
    tt = (TIME_T)t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8364
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8365
    tmPtr = localtime(&tt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8366
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8367
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8368
    day = __MKSMALLINT(tmPtr->tm_mday);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8369
%}.
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8370
    year isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8371
	i := self computeTimeAndDateFrom:osTime.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8372
	year := i at:1.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8373
	month := i at:2.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8374
	day := i at:3.
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8375
    ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8376
    aBlock value:year value:month value:day
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8377
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8378
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8379
     OperatingSystem computeDatePartsOf:0 for:[:y :m :d |
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8380
	y printCR. m printCR. d printCR
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8381
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8382
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8383
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8384
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8385
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
  8386
    "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
  8387
     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
  8388
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8389
    ^ self
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8390
	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
  8391
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8392
    "
5639
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  8393
     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
  8394
     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
  8395
     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
  8396
     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
  8397
    "
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8398
!
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8399
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8400
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
  8401
    "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
  8402
     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
  8403
     any daylight saving adjustings."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8404
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8405
    ^ self
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8406
	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
  8407
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8408
     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
  8409
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8410
!
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8411
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8412
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
  8413
    "return the OS-dependent time for the given time and day. 
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8414
     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
  8415
     otherwise, in localtime including any daylight saving adjustings."
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8416
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8417
    |osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8418
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8419
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8420
    struct tm tm;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8421
    TIME_T t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8422
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8423
    if (__bothSmallInteger(y, m) 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8424
     && __bothSmallInteger(d, h)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8425
     && __bothSmallInteger(min, s)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8426
	tm.tm_hour = __intVal(h);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8427
	tm.tm_min = __intVal(min);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8428
	tm.tm_sec = __intVal(s);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8429
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8430
	tm.tm_year = __intVal(y) - 1900;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8431
	tm.tm_mon = __intVal(m) - 1;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8432
	tm.tm_mday = __intVal(d);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8433
	tm.tm_isdst = -1;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8434
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8435
	t = mktime(&tm);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8436
	if (utcBoolean == true) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8437
	    t += TIMEZONE(&tm);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8438
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8439
	osSeconds = __MKUINT((INT)t);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8440
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8441
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8442
    osSeconds notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8443
	^ osSeconds * 1000 + millis
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8444
    ].    
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8445
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8446
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8447
    "
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8448
     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
  8449
     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
  8450
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8451
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8452
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8453
computeTimeAndDateFrom:osTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8454
    "given an OS-dependent time in osTime, return an Array
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8455
     containing (full-) year, month, day, hour, minute and seconds,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8456
     offset to UTC, daylight savings time flag, milliseconds,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8457
     dayInYear (1..) and dayInWeek (1..).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8458
     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
  8459
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8460
    |millis osSeconds ret|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8461
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8462
    millis := osTime \\ 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8463
    osSeconds := osTime // 1000.
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8464
    ret := self fillTimeAndDateFromSeconds:osSeconds into:(Array new:11).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8465
    ret at:9 put:millis.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8466
    ^ ret
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8469
     OperatingSystem computeTimeAndDateFrom:0
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8470
     OperatingSystem computeTimeAndDateFrom:1011
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8473
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8474
computeTimePartsOf:osTime for:aBlock
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8475
    "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
  8476
     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
  8477
     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
  8478
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
  8479
    |hours minutes seconds millis i|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8480
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8481
    i := self computeTimeAndDateFrom:osTime.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8482
    hours := i at:4.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8483
    minutes := i at:5.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8484
    seconds := i at:6.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8485
    millis := i at:9.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8486
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8487
    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
  8488
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8489
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8490
     OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli |
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  8491
	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
  8492
     ]
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
computeUTCTimeAndDateFrom:osTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8497
    "given an OS-dependent time in osTime, return an Array
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8498
     containing:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8499
	(full-) year, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8500
	month,                          (1..)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8501
	day,                            (1..)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8502
	hour,                           (0..23)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8503
	minute                          (0..59)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8504
	seconds,                        (0..59)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8505
	offset to UTC,                  (seconds)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8506
	daylight savings time flag, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8507
	milliseconds,                   (0..999)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8508
	dayInYear                       (1..)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8509
	dayInWeek                       (1..).
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8510
     Conversion is to utc."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8511
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8512
    |millis osSeconds ret|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8513
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8514
    millis := osTime \\ 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8515
    osSeconds := osTime // 1000.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8516
    ret := self fillTimeAndDateFromUTCSeconds:osSeconds into:(Array new:11).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8517
    ret at:9 put:millis.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8518
    ^ ret
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8519
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8520
    "
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8521
     OperatingSystem computeUTCTimeAndDateFrom:0     
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8522
     OperatingSystem computeUTCTimeAndDateFrom:1011
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8526
computeUTCTimePartsOf:osTime for:aBlock
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8527
    "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
  8528
     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
  8529
     Conversion is to UTC."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8530
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8531
    |hours minutes seconds millis osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8532
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8533
    osSeconds := osTime // 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8534
    millis := osTime \\ 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8535
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8536
    struct tm *tmPtr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8537
    long t;
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
    t = __longIntVal(osSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8540
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8541
    tmPtr = gmtime(&t);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8542
    hours = __MKSMALLINT(tmPtr->tm_hour);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8543
    minutes = __MKSMALLINT(tmPtr->tm_min);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8544
    seconds = __MKSMALLINT(tmPtr->tm_sec);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8545
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8546
    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
  8547
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8548
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8549
     OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli |
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8550
	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
  8551
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8552
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8553
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8554
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8555
fillTimeAndDateFromSeconds:osSeconds into:timeArray
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8556
    "fill the array with os-time components.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8557
     An internal helper"
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8558
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8559
    ^ self fillTimeAndDateFromSeconds:osSeconds isLocal:true into:timeArray
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8560
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8561
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8562
fillTimeAndDateFromSeconds:osSeconds isLocal:isLocalTime into:timeArray
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8563
    "fill the array with os-time components.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8564
     An internal helper"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8565
5855
dead3acb2abf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5854
diff changeset
  8566
    |low hi year month day hours minutes seconds utcOffset 
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8567
     dst yDay wDay |
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8568
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8569
%{
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8570
    struct tm *tmPtr;
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8571
    INT t;
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8572
    TIME_T tt;
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8573
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8574
    t = __longIntVal(osSeconds);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8575
    tt = (TIME_T)t;
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8576
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8577
    if (isLocalTime == true) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8578
	tmPtr = localtime(&tt);
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8579
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8580
	tmPtr = gmtime(&tt);
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8581
    }
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8582
    hours = __MKSMALLINT(tmPtr->tm_hour);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8583
    minutes = __MKSMALLINT(tmPtr->tm_min);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8584
    seconds = __MKSMALLINT(tmPtr->tm_sec);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8585
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8586
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8587
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8588
    day = __MKSMALLINT(tmPtr->tm_mday);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8589
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8590
    yDay = __MKSMALLINT(tmPtr->tm_yday+1);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8591
    wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
  8592
    utcOffset = __MKSMALLINT(TIMEZONE(tmPtr));
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
  8593
    dst = (tmPtr->tm_isdst == 0 ? false : true);
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8594
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8595
    "I would love to have SELF-like inline objects ..."
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8596
    timeArray at:1 put:year.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8597
    timeArray at:2 put:month.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8598
    timeArray at:3 put:day.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8599
    timeArray at:4 put:hours.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8600
    timeArray at:5 put:minutes.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8601
    timeArray at:6 put:seconds.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8602
    timeArray at:7 put:utcOffset.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8603
    timeArray at:8 put:dst.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8604
    timeArray at:9 put:nil.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8605
    timeArray at:10 put:yDay.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8606
    timeArray at:11 put:wDay.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8607
    ^ timeArray
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8608
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8609
    "
5855
dead3acb2abf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5854
diff changeset
  8610
     OperatingSystem fillTimeAndDateFromSeconds:0 isLocal:false into:(Array new:11)
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8611
    "
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8612
!
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8613
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8614
fillTimeAndDateFromUTCSeconds:osSeconds into:timeArray
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8615
    "fill the array with os-time components.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8616
     An internal helper"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8617
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8618
    ^ self fillTimeAndDateFromSeconds:osSeconds isLocal:false into:timeArray
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8619
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8620
    "
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8621
     OperatingSystem fillTimeAndDateFromUTCSeconds:0 into:(Array new:11)
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8622
    "
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8623
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  8624
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8625
getMicrosecondTime
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8626
    "This returns the microsecond timers value - if available. 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8627
     On some machines, times with this precision may not be available,
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8628
     on those, the returned value may be rounded towards some internal
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8629
     clock resolution value."
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8630
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8631
    |seconds millis micros|
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8632
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8633
%{
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8634
    long _seconds = 0;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8635
    long _millis = 0;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8636
    long _micros = 0;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8637
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8638
#if !defined(HAS_GETTIMEOFDAY)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8639
# if defined(HAS_FTIME)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8640
    struct timeb timebuffer;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8641
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8642
    ftime(&timebuffer);
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8643
     _seconds = timebuffer.time;
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8644
    _millis = timebuffer.millitm;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8645
#   define HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8646
# endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8647
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8648
# ifndef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8649
#  if defined(SYSV) && defined(HZ)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8650
    /* 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8651
     * sys5 time - in ticks
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8652
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8653
    long ticks;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8654
    struct tms tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8655
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8656
    ticks = times(&tb);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8657
    _seconds = ticks / HZ;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8658
    ticks -= (_seconds * HZ);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8659
    _millis = ticks * 1000 / HZ;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8660
#   define HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8661
#  endif /* old SYSV stuff */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8662
# endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8663
#endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8664
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8665
#ifndef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8666
    /* assume HAS_GETTIMEOFDAY 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8667
     * - will result in a linkage error
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8668
     * if not fixed.
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8669
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8670
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8671
    /*
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8672
     * bsd time
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8673
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8674
    struct timeval tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8675
    /* struct timezone tzb; */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8676
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8677
    gettimeofday(&tb, NULL /* &tzb */);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8678
    _seconds = tb.tv_sec;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8679
    _micros = tb.tv_usec;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8680
    if (_micros >= (1000*1000)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8681
	printf("oops\n");
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8682
    }
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8683
#endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8684
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8685
#undef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8686
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8687
    seconds = __MKINT(_seconds);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8688
    millis = __MKINT(_millis);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8689
    micros = __MKINT(_micros);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8690
%}.
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8691
    ^ (((seconds * 1000) + millis) * 1000) + micros
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8693
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8694
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8695
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8696
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8697
!
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8698
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8699
getMillisecondTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8700
    "This returns the millisecond timers value. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8701
     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
  8702
     LargeInteger arithmetic when doing timeouts and delays.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8703
     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
  8704
     short relative time deltas.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8705
     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
  8706
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8707
     BAD DESIGN:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8708
	This should be changed to return some instance of RelativeTime,
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8709
	and these computations moved there.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8710
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8711
     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
  8712
     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
  8713
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8714
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8715
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8716
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8717
    long t = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8718
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8719
#if !defined(HAS_GETTIMEOFDAY)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8720
# if defined(HAS_FTIME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8721
    struct timeb timebuffer;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8722
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8723
    ftime(&timebuffer);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8724
    t = (timebuffer.time * 1000) + timebuffer.millitm;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8725
#   define HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8726
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8728
# ifndef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8729
#  if defined(SYSV) && defined(HZ)
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
     * sys5 time
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
    long ticks;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8734
    struct tms tb;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8735
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8736
    ticks = times(&tb);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8737
    t = (ticks * 1000) / HZ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8738
#   define HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8739
#  endif /* old SYSV stuff */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8740
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8741
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8742
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8743
#ifndef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8744
    /* assume HAS_GETTIMEOFDAY 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8745
     * - will result in a linkage error
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8746
     * if not fixed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8747
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8748
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8749
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8750
     * bsd time
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8751
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8752
    struct timeval tb;
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8753
    /* struct timezone tzb; */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8754
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8755
    gettimeofday(&tb, NULL /* &tzb */);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8756
    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
  8757
#endif
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
#undef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8760
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8761
    RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) );
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8762
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8763
    self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8764
!
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
getOSTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8767
    "This returns the OS time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8768
     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
  8769
     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
  8770
     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
  8771
     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
  8772
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8773
     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
  8774
     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
  8775
     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
  8776
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8777
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8778
    |time seconds millis|
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8779
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8780
    time := self primGetOSTime.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8781
    time isArray ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8782
	seconds := time at:1.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8783
	millis := time at:2.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8784
	time := (seconds * 1000) + millis
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8785
    ].
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8786
    ^ time
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8787
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8788
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8789
     OperatingSystem getOSTime printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8790
     Delay waitForSeconds:0.2.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8791
     OperatingSystem getOSTime printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8792
    "
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8795
millisecondDelay:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8796
    "delay execution for millis milliseconds or until the next event
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8797
     arrives.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8798
     All lower priority threads will also sleep for the duration, 
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8799
     interrupts (and therefore, higher prio processes) are still handled. 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8800
     Better use a Delay, to only delay the calling thread.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8801
     (however, a delay cannot be used in the event handler or scheduler)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8802
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8803
    |now then delta|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8804
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8805
    now := UnixOperatingSystem getMillisecondTime.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8806
    then := UnixOperatingSystem millisecondTimeAdd:now and:millis.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8807
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8808
    [UnixOperatingSystem millisecondTime:then isAfter:now] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8809
	delta := UnixOperatingSystem millisecondTimeDeltaBetween:then and:now.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8810
	self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8811
	now := UnixOperatingSystem getMillisecondTime.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8812
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8813
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8814
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8815
     OperatingSystem millisecondDelay:2000
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8816
    "
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8817
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8818
    "Modified: / 5.6.1998 / 18:42:17 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8819
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8820
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8821
primGetOSTime
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8822
    "This returns the OS time.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8823
     The base of the returned value is not consistent across
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8824
     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
  8825
     others since 1900. The Time classes are prepared for this, and 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8826
     converts as appropriate (by using my fromOSTime: conversion methods).
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8827
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8828
     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
  8829
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8830
     or use instances of Time, Date or AbsoluteTime to work with.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8831
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8832
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8833
    |seconds millis|
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8834
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8835
%{
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8836
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8837
    long t;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8838
    long _secs, _millis;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8839
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8840
#if !defined(HAS_GETTIMEOFDAY) 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8841
# if defined(HAS_FTIME)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8842
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8843
	struct timeb timebuffer;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8844
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8845
	ftime(&timebuffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8846
	_secs = timebuffer.time;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8847
	_millis = timebuffer.millitm;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8848
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8849
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8850
# endif /* HAS_FTIME */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8851
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8852
# ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8853
#  if defined(SYSV) && defined(HZ)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8854
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8855
	/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8856
	 * sys5 time; we have to fake the information
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8857
	 * the returned value is inexact.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8858
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8859
	long ticks;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8860
	struct tms tb;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8861
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8862
	_secs = time(0);   /* seconds since 1970 ... */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8863
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8864
	ticks = times(&tb);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8865
	t = (ticks * 1000) / HZ;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8866
	t = t % 1000;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8867
	_millis = __MKSMALLINT(t);
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8868
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8869
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8870
#  endif /* OLD SYSV stuff */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8871
# endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8872
#endif /* no HAS_GETTIMEOFDAY */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8873
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8874
#ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8875
    /*
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8876
     * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8877
     * 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
  8878
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8879
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8880
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8881
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8882
	 * bsd time
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8883
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8884
	struct timeval tb;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8885
	/* struct timezone tzb; */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8886
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8887
	gettimeofday(&tb, NULL /* &tzb */);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8888
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8889
	_secs = tb.tv_sec;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8890
	_millis = tb.tv_usec / 1000;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8891
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8892
#endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8893
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8894
    /* 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8895
     * mhmh long-long stuff seems not to work correctly 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8896
     * on all machines (sparc)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8897
     * being conservative here ...
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8898
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8899
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8900
#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(i386) && defined(LINUX)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8901
# define HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8902
#endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8903
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8904
#ifdef alpha64
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8905
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8906
	unsigned INT _lsecs, _lmillis, rslt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8907
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8908
	_lsecs = (INT)_secs;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8909
	_lmillis = (INT)_millis;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8910
	rslt = _lsecs * 1000 + _lmillis;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8911
	RETURN (__MKUINT(rslt));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8912
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8913
#else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8914
# ifdef HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8915
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8916
	unsigned long long _lsecs, _lmillis, rslt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8917
	unsigned low, hi;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8918
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8919
	_lsecs = (long long)_secs;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8920
	_lmillis = (long long)_millis;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8921
	rslt = _lsecs * 1000 + _lmillis;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8922
	low = rslt & 0xFFFFFFFF;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8923
	hi = rslt >> 32;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8924
	RETURN (__MKLARGEINT64(1, low, hi));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8925
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8926
# else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8927
    seconds = __MKUINT(_secs);
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8928
    millis = __MKUINT(_millis);
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8929
    RETURN (__ARRAY_WITH2(seconds, millis));
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8930
# endif /* long long */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8931
#endif /* alpha64 */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8932
%}.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8933
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8934
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8935
     OperatingSystem primGetOSTime printCR.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8936
     Delay waitForSeconds:0.2.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8937
     OperatingSystem primGetOSTime printCR.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8938
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8939
!
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8940
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8941
sleep:numberOfSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8942
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8943
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8944
    "cease ANY action for some time. This suspends the whole smalltalk
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8945
     (unix-) process for some time if running threadless;
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8946
     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
  8947
     only block until the next clock tick and return with the next
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8948
     timer interrupt.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8949
     Use either OperatingSystem>>millisecondDelay: (which makes all
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8950
     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
  8951
     only the calling thread sleep)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8952
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8953
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8954
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8955
    if (__isSmallInteger(numberOfSeconds)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8956
	sleep(__intVal(numberOfSeconds));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8957
	RETURN ( self );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8958
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8959
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8960
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8961
     argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8962
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8963
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8964
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8965
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8966
     OperatingSystem sleep:2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8967
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8968
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8969
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8970
!UnixOperatingSystem class methodsFor:'users & groups'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8971
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8972
getEffectiveGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8973
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8974
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8975
    "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
  8976
     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
  8977
     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
  8978
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8979
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8980
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8981
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8982
    uid = getegid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8983
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8984
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8985
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8986
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8987
     OperatingSystem getEffectiveGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8988
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8989
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8990
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8991
getEffectiveUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8992
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8993
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8994
    "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
  8995
     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
  8996
     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
  8997
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8998
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8999
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9000
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9001
    uid = geteuid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9002
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9003
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9005
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9006
     OperatingSystem getEffectiveUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9007
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9008
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9009
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9010
getFullUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9011
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9012
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9013
    "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
  9014
     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
  9015
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9016
    |info gecos|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9017
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9018
    info := self userInfoOf:userID.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9019
    (info notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9020
    and:[info includesKey:#gecos]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9021
	gecos := info at:#gecos.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9022
	(gecos includes:$,) ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9023
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9024
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9025
	^ gecos
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9026
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9027
    ^ self getUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9028
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9029
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9030
     OperatingSystem getFullUserNameFromID:0 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9031
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9032
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9033
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9034
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9035
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9036
    "Modified: 15.7.1996 / 12:44:21 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9037
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9038
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9039
getGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9040
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9041
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9042
    "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
  9043
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9044
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9045
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9046
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9047
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9048
    uid = getgid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9049
    RETURN ( __MKSMALLINT(uid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9050
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9051
    ^ 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
  9052
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9053
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9054
     OperatingSystem getGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9055
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9056
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9057
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9058
getGroupNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9059
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9060
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9061
    "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
  9062
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9063
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9064
    struct group *g;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9065
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9066
    if (__isSmallInteger(aNumber)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9067
	g = getgrgid(__intVal(aNumber));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9068
	if (g) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9069
	    RETURN ( __MKSTRING(g->gr_name) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9070
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9071
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9072
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9073
    ^ '???'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9074
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9075
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9076
     OperatingSystem getGroupNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9077
     OperatingSystem getGroupNameFromID:10
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9078
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9079
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9080
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9081
getHomeDirectory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9082
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9083
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9084
    "return the name of the users home directory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9085
     (i.e. yours)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9086
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9087
    ^ UnixOperatingSystem getEnvironment:'HOME'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9088
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9089
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9090
     OperatingSystem getHomeDirectory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9091
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9092
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9093
    "Modified: 24.1.1997 / 11:32:13 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9094
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9095
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9096
getLoginName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9097
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9098
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9099
    "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
  9100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9101
%{  /* NOCONTEXT */
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  9102
    static char cachedName[128];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9103
    static firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9104
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9105
    extern char *getlogin();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9106
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9107
    char *name = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9108
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9109
    if (firstCall) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9110
	name = getlogin();
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9111
	if (! name || (name[0] == 0)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9112
	    name = getenv("LOGNAME");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9113
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9114
	if (name && (strlen(name) < sizeof(cachedName))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9115
	    strcpy(cachedName, name);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9116
	    firstCall = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9117
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9118
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9119
	name = cachedName;
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9120
    }
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9121
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9122
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9123
     * try a few common environment variables ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9124
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9125
    if (! name || (name[0] == 0) ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9126
	name = getenv("LOGIN");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9127
	if (! name || (name[0] == 0) ) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9128
	    name = getenv("LOGNAME");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9129
	    if (! name || (name[0] == 0) ) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9130
		name = getenv("USER");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9131
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9132
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9133
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9134
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9135
     * nope - I really font know who you are.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9136
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9137
    if (! name || (name[0] == 0) ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9138
	name = "you";
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9139
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9141
    RETURN ( __MKSTRING(name) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9142
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9143
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9144
     OperatingSystem getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9145
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9146
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9147
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9148
getUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9149
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9150
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9151
    "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
  9152
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9153
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9154
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9155
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9157
    uid = getuid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9158
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9159
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9160
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9161
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9162
     OperatingSystem getUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9163
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9164
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9165
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9166
getUserNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9167
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9168
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9169
    "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
  9170
     This is the login name, not the fullName."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9172
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9173
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9174
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9175
    struct passwd *p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9176
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9177
    if (__isSmallInteger(aNumber)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9178
	p = getpwuid(__intVal(aNumber));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9179
	if (p) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9180
	    RETURN ( __MKSTRING(p->pw_name) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9181
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9182
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9183
#endif /* unix-like */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9184
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9185
    aNumber == self getUserID ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9186
	^ self getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9187
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9188
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9189
    ^ '? (' , aNumber printString , ')'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9190
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9191
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9192
     OperatingSystem getUserNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9193
     OperatingSystem getUserNameFromID:100
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9194
     OperatingSystem getUserNameFromID:9991 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9195
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9196
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9197
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9198
userInfoOf:aNameOrID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9199
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9201
    "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
  9202
     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
  9203
     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
  9204
     DOS systems return nothing; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9205
     non-SYSV4 systems have no age/comment.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9206
     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
  9207
     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
  9208
     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
  9209
     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
  9210
     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
  9211
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9212
    |info name passw uid gid age comment
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9213
     gecos dir shell|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9214
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9215
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9216
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9217
    struct passwd *buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9218
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9219
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9220
    if (__isString(aNameOrID)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9221
	buf = getpwnam(__stringVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9222
    } else if (__isSmallInteger(aNameOrID)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9223
	buf = getpwuid(__intVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9224
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9225
	buf = (struct passwd *)0;
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
    if (buf) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9228
	name = __MKSTRING(buf->pw_name);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9229
#  ifndef NO_PWD_PASSWD
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9230
	passw = __MKSTRING(buf->pw_passwd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9231
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9232
#  ifdef SYSV4
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9233
	age = __MKSTRING(buf->pw_age);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9234
	comment = __MKSTRING(buf->pw_comment);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9235
#  endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9236
	dir = __MKSTRING(buf->pw_dir);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9237
#  ifndef NO_PWD_GECOS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9238
	gecos = __MKSTRING(buf->pw_gecos);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9239
#  endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9240
	shell = __MKSTRING(buf->pw_shell);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9241
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9242
	uid = __MKSMALLINT(buf->pw_uid);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9243
	gid = __MKSMALLINT(buf->pw_gid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9244
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9245
# endif /* has PWD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9246
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9247
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9248
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9249
	aNameOrID == self getUserID ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9250
	    name := self getLoginName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9251
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9252
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9253
    name notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9254
	info at:#name put:name.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9255
    ] ifFalse:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9256
	info at:#name put:'unknown'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9257
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9258
    passw notNil ifTrue:[info at:#passwd put:passw].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9259
    age notNil ifTrue:[info at:#age put:age].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9260
    comment notNil ifTrue:[info at:#comment put:comment].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9261
    gecos notNil ifTrue:[info at:#gecos put:gecos].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9262
    shell notNil ifTrue:[info at:#shell put:shell].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9263
    dir isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9264
	aNameOrID == self getUserID ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9265
	    dir := self getHomeDirectory
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9266
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9267
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9268
    dir notNil ifTrue:[info at:#dir put:dir].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9269
    uid notNil ifTrue:[info at:#uid put:uid].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9270
    gid  notNil ifTrue:[info at:#gid put:gid].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9271
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9272
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9273
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9274
     OperatingSystem userInfoOf:'root'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9275
     OperatingSystem userInfoOf:1
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9276
     OperatingSystem userInfoOf:'claus' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9277
     OperatingSystem userInfoOf:'fooBar' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9278
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9279
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9280
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9281
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9282
!UnixOperatingSystem class methodsFor:'waiting for events'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9283
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9284
blockingChildProcessWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9285
     "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
  9286
      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
  9287
      a subprocesses status (to avoid blocking)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9288
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9289
%{ /*NOCONTEXT*/
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  9290
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9291
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9292
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9293
    RETURN(true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9294
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9295
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9296
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9297
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9298
childProcessWait:blocking pid:pidToWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9299
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9300
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9301
    "get status changes from child processes.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9302
     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
  9303
     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
  9304
     otherwise we return immediately.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9305
     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
  9306
     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
  9307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9308
    |pid status code core|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9309
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9310
    int p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9311
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9312
#if defined(HAS_WAITPID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9314
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9315
#   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
  9316
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9317
#else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9318
# if defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9319
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9320
    union wait s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9321
#   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
  9322
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9323
# 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
  9324
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9325
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9326
#   define __WAIT      wait(&s)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9327
#   define __BLOCKING_WAIT__ 1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9328
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9329
    if (blocking != true) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9330
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9331
	 * We do not support nonBlocking waits, so signal an error
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9332
	 * Sorry about the goto, but with all these ifdefs ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9333
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9334
	goto done;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9335
    }
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9336
# endif /*!HAS_WAIT3*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9337
#endif  /*!HAS_WAITPID*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9338
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9339
#if !defined(WIFEXITED)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9340
# define WIFEXITED(stat)      (((int)((stat)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9341
# 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
  9342
# 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
  9343
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9344
# define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9345
# define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9346
# define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9347
#endif /*!WIFEXITED*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9348
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9349
#if !defined(WCOREDUMP)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9350
   /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9351
    * 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
  9352
    */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9353
# if defined(HAS_WAIT3)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9354
#  define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9355
# else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9356
#  define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9357
# endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9358
#endif /*!WCOREDUMP*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9359
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9360
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9361
    __BEGIN_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9362
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9363
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9364
    do {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9365
	p = __WAIT;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9366
    } while (p == -1 && errno == EINTR);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9367
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9368
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9369
    __END_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9370
#  undef __BLOCKING_WAIT__
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9371
#endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9372
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9373
#undef __WAIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9374
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9375
    if (p == 0)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9376
	RETURN(nil)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9377
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9378
    if (p == -1) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9379
	if (errno == ECHILD)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9380
	    RETURN(nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9381
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9382
	pid = __MKSMALLINT(p);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9383
	if (WIFEXITED(s)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9384
	    status = @symbol(exit);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9385
	    code = __MKSMALLINT(WEXITSTATUS(s));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9386
	    core = WCOREDUMP(s) ? true : false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9387
	} else if (WIFSIGNALED(s)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9388
	    status = @symbol(signal);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9389
	    code = __MKSMALLINT(WTERMSIG(s));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9390
	} else if (WIFSTOPPED(s)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9391
	    status = @symbol(stop);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9392
	    code = __MKSMALLINT(WSTOPSIG(s));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9393
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9394
#if defined(WIFCONTINUED)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9395
	else if (WIFCONTINUED(s)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9396
	    status = @symbol(continue);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9397
	} 
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9398
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9399
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9400
done: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9401
%}.
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
    (status isNil or:[pid isNil]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9404
	^ self primitiveFailed
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9407
"/ 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
  9408
"/ show:' code: '; show:code; show:' core:'; showCR:core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9409
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9410
    ^ 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
  9411
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9412
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9413
     OperatingSystem childProcessWait:false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9414
    "
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
    "Created: 5.1.1996 / 16:39:14 / stefan"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9419
numAvailableForReadOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9420
    "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
  9421
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9422
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9423
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9424
     * 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
  9425
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9426
# if 0 && defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9427
    {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9428
	int n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9429
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9430
	if (__isSmallInteger(fd)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9431
	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9432
		RETURN (__MKINT(n));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9433
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9434
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9435
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9436
# endif /* FIONREAD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9437
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9438
    ^ (self readCheck:fd) ifTrue:[1] ifFalse:[0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9439
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9440
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9441
readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9442
    "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
  9443
     (i.e. read is possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9444
     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
  9445
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9446
%{
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
     * 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
  9449
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9450
#if 0 && defined(FIONREAD)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9451
    if (__isSmallInteger(fd)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9452
	int result = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9453
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9454
	if (ioctl(__smallIntegerVal(fd), FIONREAD, &result) >= 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9455
	    RETURN(result > 0 ? true : false);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9456
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9457
    }
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9458
#endif /* FIONREAD */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9459
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9460
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9461
    ^ super readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9462
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9463
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9464
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9465
    "wait for any fd in readFdArray (an Array of integers) to become ready for 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9466
     reading, writeFdArray to become ready for writing, or exceptFdArray to 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9467
     arrive exceptional data (i.e. out-of-band data).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9468
     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
  9469
     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
  9470
     descriptors (i.e. to check if I/O possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9471
     Return first ready fd if I/O ok, nil if timed-out or interrupted."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9472
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9473
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9474
    fd_set rset, wset, eset;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9475
    struct timeval wt, et;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9476
    int f, maxF, i, lX, bX;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9477
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9478
    OBJ fd, retFd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9479
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9480
    int count;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9481
    int numFds = 0;
3801
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9482
#ifndef __isArrayLike
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9483
# define __isArrayLike __isArray
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  9484
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9485
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9486
    if (__isSmallInteger(millis)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9487
	FD_ZERO(&rset);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9488
	FD_ZERO(&wset);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9489
	FD_ZERO(&eset);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9490
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9491
	maxF = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9492
	if (__isNonNilObject(readFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9493
	    if (! __isArrayLike(readFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9494
		goto fail;    
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9495
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9496
	    count = __arraySize(readFdArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9497
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9498
	    for (i=0; i<count;i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9499
		fd = __ArrayInstPtr(readFdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9500
		if (fd != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9501
		    if (! __isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9502
			if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9503
			    fprintf(stderr, "[OS] warning: funny read-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9504
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9505
		    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9506
			f = __intVal(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9507
			if ((unsigned)f < FD_SETSIZE) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9508
			    FD_SET(f, &rset);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9509
			    if (f > maxF) maxF = f;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9510
			    numFds++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9511
			} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9512
			    if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9513
				fprintf(stderr, "[OS] warning: huge read-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9514
			    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9515
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9516
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9517
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9518
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9519
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9520
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9521
	if (__isNonNilObject(writeFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9522
	    if (! __isArrayLike(writeFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9523
		goto fail;    
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9524
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9525
	    count = __arraySize(writeFdArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9526
	    for (i=0; i<count;i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9527
		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9528
		if (fd != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9529
		    if (! __isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9530
			if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9531
			    fprintf(stderr, "[OS] warning: funny write-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9532
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9533
		    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9534
			f = __intVal(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9535
			if ((unsigned)f < FD_SETSIZE) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9536
			    FD_SET(f, &wset);       
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9537
			    if (f > maxF) maxF = f;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9538
			    numFds++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9539
			} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9540
			    if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9541
				fprintf(stderr, "[OS] warning: huge write-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9542
			    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9543
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9544
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9545
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9546
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9547
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9548
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9549
	if (__isNonNilObject(exceptFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9550
	    if (! __isArrayLike(exceptFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9551
		goto fail;    
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9552
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9553
	    count = __arraySize(exceptFdArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9554
	    for (i=0; i<count;i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9555
		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9556
		if (fd != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9557
		    if (! __isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9558
			if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9559
			    fprintf(stderr, "[OS] warning: funny except-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9560
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9561
		    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9562
			f = __intVal(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9563
			if ((unsigned)f < FD_SETSIZE) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9564
			    FD_SET(f, &eset);       
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9565
			    if (f > maxF) maxF = f;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9566
			    numFds++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9567
			} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9568
			    if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9569
				fprintf(stderr, "[OS] warning: huge except-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9570
			    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9571
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9572
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9573
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9574
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9575
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9576
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9577
	t = __intVal(millis);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9578
	if (t) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9579
	    wt.tv_sec = t / 1000;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9580
	    wt.tv_usec = (t % 1000) * 1000;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9581
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9582
	    wt.tv_sec = wt.tv_usec = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9583
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9584
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9585
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9586
	 * make certain, that interrupt gets us out of the select
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9587
	 * However, we must then care for moved objects.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9588
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9589
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9590
	errno = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9591
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9592
	if (t == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9593
	    /* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9594
	     * if there is no timeout time, we can stay here interruptable.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9595
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9596
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9597
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9598
	    } while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9599
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9600
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9601
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9602
		/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9603
		 * for now: dont loop; if we did, we had to adjust the vt-timeval;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9604
		 * could otherwise stay in this loop forever ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9605
		 * Premature ret (before the time expired) must be handled by the caller.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9606
		 * A good solution is to update the wt-timeval and redo the select.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9607
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9608
	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9609
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9610
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9611
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9612
	if (ret > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9613
	    for (i=0; i <= maxF; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9614
		if (FD_ISSET(i, &rset)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9615
		 || FD_ISSET(i, &wset)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9616
		 || FD_ISSET(i, &eset)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9617
		    RETURN ( __MKSMALLINT(i) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9618
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9619
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9620
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9621
	    if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9622
		if (errno == EINTR) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9623
		    errno = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9624
		    @global(LastErrorNumber) = nil;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9625
		} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9626
		    if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9627
			fprintf(stderr, "OS [info]: select errno = %d\n", errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9628
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9629
		    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9630
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9631
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9632
		@global(LastErrorNumber) = nil;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9633
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9634
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9635
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9636
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9637
	 * Return nil (means time expired or interrupted)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9638
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9639
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9640
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9641
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9642
fail: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9643
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9644
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9645
     timeout argument not integer,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9646
     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
  9647
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9648
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9649
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9650
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9651
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9652
setBlocking:aBoolean on:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9653
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9654
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9655
    "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
  9656
     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
  9657
     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
  9658
     nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9659
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9660
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9661
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9662
    int ret, flags;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9663
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9664
#if defined(F_GETFL) && defined(F_SETFL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9665
# if defined(FNDELAY)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9666
    if (__isSmallInteger(fd)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9667
	int f = __intVal(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9668
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9669
	flags = fcntl(f, F_GETFL, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9670
	if (aBoolean == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9671
	    ret = fcntl(f, F_SETFL, flags & ~FNDELAY);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9672
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9673
	    ret = fcntl(f, F_SETFL, flags | FNDELAY);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9674
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9675
	if (ret >= 0) ret = flags;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9676
	RETURN ( __MKSMALLINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9677
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9678
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9679
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9680
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9681
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9682
     fd argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9683
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9684
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9685
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9686
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9687
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9688
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9689
update:aspect with:argument from:anObject
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9690
    "one of our registered handles has been collected"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9691
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9692
    aspect == #ElementExpired ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9693
	OpenFiles keysAndValuesDo:[:fd :handle |
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9694
	    handle == 0 ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9695
		"Have to close the file descriptor"
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9696
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9697
		OperatingSystem closeFd:fd.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9698
		OpenFiles at:fd put:nil.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9699
	    ].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9700
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9701
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9702
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9703
    "Created: 30.9.1997 / 12:57:35 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9704
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9705
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9706
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9707
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9708
initialize
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9709
     OpenFiles := WeakArray new:10.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9710
     OpenFiles addDependent:self. 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9711
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9712
     "self initialize"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9713
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9714
    "Created: 26.9.1997 / 17:15:50 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9715
    "Modified: 30.9.1997 / 12:40:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9716
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9717
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9718
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9719
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9720
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9721
    "create an instance of myself for a given fileDescriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9722
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9723
    ^ self new for:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9724
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9725
    "Created: 30.9.1997 / 14:00:00 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9726
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9727
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9728
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9729
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9730
error:anError
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9731
    "got an error with anInteger as error number"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9732
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9733
    anError isInteger ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9734
	^ UnixOperatingSystem errorHolderForNumber:anError
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9735
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9736
    self primitiveFailed:anError.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9737
! !
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
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9740
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9741
close
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9742
    "close the descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9743
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9744
    |desc|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9745
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9746
    desc := fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9747
    self invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9748
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9749
    ^ OperatingSystem closeFd:desc.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9750
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9751
    "Modified: 30.9.1997 / 13:06:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9752
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9753
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9754
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9755
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9756
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9757
    "create file for a handle"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9758
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9759
    |oldHandle|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9760
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9761
    fd := aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9762
    oldHandle := OpenFiles at:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9763
    (oldHandle notNil and:[oldHandle ~~ self]) ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9764
	oldHandle invalidate.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9765
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9766
    self register.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9767
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9768
    "Created: 26.9.1997 / 17:14:40 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9769
    "Modified: 30.9.1997 / 12:41:43 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9770
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9771
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9772
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9773
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9774
readBytes:count into:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9775
    "read count bytes into a byte-buffer;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9776
     Return the number of bytes read.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9777
     The read is non-blocking. If the operation would block
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9778
     either an incomplete count or nil will be returned.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9779
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9780
     An exception is raised on any other error"
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9781
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9782
    |error|
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9783
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9784
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9785
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9786
    int nRead = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9787
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9788
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9789
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9790
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9791
    if (! __isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9792
	error = @symbol(errorNotOpen);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9793
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9794
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9795
    if (! __bothSmallInteger(count, firstIndex)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9796
	error = @symbol(badArgument);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9797
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9798
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9799
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9800
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9801
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9802
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9803
    if (fd < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9804
	error = @symbol(internalError);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9805
	goto bad;
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
    if (__isExternalBytes(aByteBuffer)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9808
	OBJ sz;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9809
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9810
	nInstBytes = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9811
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9812
	sz = __externalBytesSize(aByteBuffer);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9813
	if (__isSmallInteger(sz)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9814
	    objSize = __smallIntegerVal(sz);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9815
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9816
	    objSize = -1; /* unknown */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9817
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9818
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9819
	OBJ oClass;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9820
	int nInstVars;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9821
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9822
	oClass = __Class(aByteBuffer);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9823
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9824
	    case BYTEARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9825
	    case WORDARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9826
	    case LONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9827
	    case SWORDARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9828
	    case SLONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9829
	    case FLOATARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9830
	    case DOUBLEARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9831
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9832
	    default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9833
		error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9834
		goto bad;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9835
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9836
	extPtr = (char *)0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9837
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9838
	nInstBytes = __OBJS2BYTES__(nInstVars);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9839
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9840
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9841
    if ((offs >= 0)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9842
	&& (cnt >= 0)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9843
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9844
	nRead = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9845
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9846
	do {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9847
	    int n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9848
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9849
	    if (extPtr) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9850
		n = read(fd, extPtr+offs, cnt);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9851
	    } else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9852
		char *bp;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9853
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9854
		/*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9855
		 * on interrupt, anObject may be moved to another location.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9856
		 * So we recompute the byte-address here.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9857
		 */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9858
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9859
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9860
		n = read(fd, bp + offs, cnt);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9861
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9862
	    if (n > 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9863
		cnt -= n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9864
		offs += n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9865
		nRead += n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9866
	    } else if (n == 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9867
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9868
	    } else if (n < 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9869
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9870
#ifdef EWOULDBLOCK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9871
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9872
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9873
#ifdef EAGAIN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9874
		    || errno == EAGAIN
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9875
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9876
		) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9877
		     RETURN(nil);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9878
		}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9879
		if (errno != EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9880
		     error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9881
		     goto bad;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9882
		}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9883
		__HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9884
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9885
	} while (cnt > 0);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9886
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9887
	RETURN (__mkSmallInteger(nRead));
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
bad: ;   
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9890
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9891
    ^ self error:error.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9892
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9893
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9894
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9895
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9896
     h := OperatingSystem openFileForRead:'/etc/hosts'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9897
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9898
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9899
     Transcript show:n; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9900
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9901
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9902
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9903
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9904
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9905
     h := OperatingSystem openFileForRead:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9906
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9907
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9908
     Transcript show:n printString; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9909
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9910
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9911
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9912
writeBytes:count from:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9913
    "write count bytes from a byte-buffer;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9914
     Return the number of bytes written (negative on error)"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9915
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9916
    |error|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9917
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9918
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9919
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9920
    int nWritten = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9921
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9922
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9923
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9924
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9925
    if (! __isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9926
	error = @symbol(errorNotOpen);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9927
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9928
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9929
    if (! __bothSmallInteger(count, firstIndex)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9930
	error = @symbol(badArgument);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9931
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9932
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9933
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9934
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9935
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9936
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9937
    if (fd < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9938
	error = @symbol(internalError);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9939
	goto bad;
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
    if (__isExternalBytes(aByteBuffer)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9942
	OBJ sz;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9943
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9944
	nInstBytes = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9945
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9946
	sz = __externalBytesSize(aByteBuffer);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9947
	if (__isSmallInteger(sz)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9948
	    objSize = __smallIntegerVal(sz);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9949
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9950
	    objSize = -1; /* unknown */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9951
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9952
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9953
	OBJ oClass;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9954
	int nInstVars;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9955
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9956
	oClass = __Class(aByteBuffer);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9957
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9958
	    case BYTEARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9959
	    case WORDARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9960
	    case LONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9961
	    case SWORDARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9962
	    case SLONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9963
	    case FLOATARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9964
	    case DOUBLEARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9965
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9966
	    default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9967
		error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9968
		goto bad;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9969
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9970
	extPtr = (char *)0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9971
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9972
	nInstBytes = __OBJS2BYTES__(nInstVars);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9973
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9974
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9975
    if ((offs >= 0)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9976
	&& (cnt >= 0)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9977
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9978
	nWritten = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9979
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9980
	do {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9981
	    int n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9982
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9983
	    if (extPtr) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9984
		n = write(fd, extPtr+offs, cnt);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9985
	    } else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9986
		char *bp;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9987
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9988
		/*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9989
		 * on interrupt, anObject may be moved to another location.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9990
		 * So we recompute the byte-address here.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9991
		 */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9992
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9993
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9994
		n = write(fd, bp + offs, cnt);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9995
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9996
	    if (n > 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9997
		cnt -= n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9998
		offs += n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  9999
		nWritten += n;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10000
	    } else if (n == 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10001
		break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10002
	    } else if (n < 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10003
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10004
#ifdef EWOULDBLOCK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10005
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10006
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10007
#ifdef EAGAIN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10008
		    || errno == EAGAIN
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10009
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10010
		) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10011
		     RETURN(nil);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10012
		}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10013
		if (errno != EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10014
		     error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10015
		     goto bad;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10016
		}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10017
		__HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10018
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10019
	} while (cnt > 0);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10020
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10021
	RETURN (__mkSmallInteger(nWritten));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10022
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10023
bad: ;   
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10024
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10025
    ^ self error:error
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10026
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10027
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10028
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10029
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10030
     h := OperatingSystem createFileForReadWrite:'/tmp/xx'.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10031
     buff := '12345678901234567890'.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10032
     n := h writeBytes:10 from:buff startingAt:1.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10033
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10034
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10035
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10036
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10037
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10038
     h := OperatingSystem createFileForReadWrite:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10039
     buff := '12345678901234567890'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10040
     n := h writeBytes:10 from:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10041
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10042
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10043
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10044
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10045
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10046
seekTo:newPosition from:whence
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10047
    "seek to newPosition
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10048
     whence is one of: #begin #current #end.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10049
     Return the new position.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10050
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10051
     TODO: 64 bit handling"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10052
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10053
    |error|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10054
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10055
%{
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10056
    INT fd, pos, ret;
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10057
    INT __whence;
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10058
    __uint64__ pos64;
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10059
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10060
    if (! __isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10061
	error = @symbol(errorNotOpen);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10062
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10063
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10064
    if (__isSmallInteger(newPosition)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10065
	pos = __smallIntegerVal(newPosition);
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10066
    } else if (__signedLong64IntVal(newPosition, &pos64) == 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10067
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10068
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10069
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10070
    fd = __smallIntegerVal(__INST(fd));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10071
    if (fd < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10072
	error = @symbol(internalError);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10073
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10074
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10075
    if (whence == @symbol(begin)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10076
	__whence = SEEK_SET;    
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10077
    } else if (whence == @symbol(current)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10078
	__whence = SEEK_CUR;    
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10079
    } else if (whence == @symbol(end)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10080
	__whence = SEEK_END;    
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10081
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10082
	error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10083
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10084
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10085
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10086
again:
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10087
    ret = lseek(fd, pos, __whence);
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10088
    if (ret < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10089
	if (errno == EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10090
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10091
	    goto again;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10092
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10093
	error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10094
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10095
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10096
    /* RETURN (__mkInteger(ret)); */
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10097
    RETURN (__mkSmallInteger(ret));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10098
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10099
bad: ;   
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10100
%}.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10101
    ^ self error:error.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10102
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10103
    "
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10104
     |h buff n|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10105
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10106
     h := OperatingSystem openFileForRead:'/etc/hosts'.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10107
     h seekTo:10 from:#begin.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10108
     buff := ByteArray new:1000. buff inspect.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10109
     n := h readBytes:1000 into:buff startingAt:1.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10110
     Transcript show:n; space; showCR:buff asString.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10111
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10112
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10113
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10114
selectWithTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10115
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10116
     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
 10117
     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
 10118
     of read-data.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10119
     Experimental."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10120
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10121
    ^ OperatingSystem selectOnAnyReadable:(Array with:fd)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10122
		      writable:(Array with:fd)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10123
		     exception:nil
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10124
		   withTimeOut:millis
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10125
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10126
    "Created: 1.10.1997 / 08:51:11 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10127
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10128
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10129
setBlocking:aBoolean
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10130
    "{ Pragma: +optSpace }"
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
    "set/clear the blocking attribute - if set (which is the default)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10133
     a read on the fileDescriptor will block until data is available.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10134
     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
 10135
     nil if no data is available."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10136
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10137
    |err|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10138
%{  
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10139
    int ret, flags;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10140
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10141
#if defined(F_GETFL) && defined(F_SETFL)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10142
# if defined(O_NDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10143
#  define DELAY O_NDELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10144
# else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10145
#  if defined(FNDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10146
#   define DELAY FNDELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10147
#  endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10148
# endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10149
# if defined(DELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10150
    if (__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10151
	int f = __intVal(__INST(fd));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10152
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10153
	flags = fcntl(f, F_GETFL, 0);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10154
	if (aBoolean == true) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10155
	    ret = fcntl(f, F_SETFL, flags & ~DELAY);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10156
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10157
	    ret = fcntl(f, F_SETFL, flags | DELAY);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10158
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10159
	if (ret >= 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10160
	    RETURN(__MKSMALLINT(flags)); 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10161
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10162
	    err = __MKSMALLINT(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10163
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10164
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10165
# undef DELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10166
# endif /* DELAY */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10167
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10168
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10169
    err notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10170
	self error:err
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10171
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10172
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10173
     fd argument not integer
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10174
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10175
    ^ self primitiveFailed
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10176
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10177
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10178
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10179
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10180
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'private accessing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10181
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10182
setFileDescriptor:anInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10183
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10184
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10185
    if (__isSmallInteger(anInteger)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10186
	__externalAddressVal(self) = (OBJ)(__smallIntegerVal(anInteger));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10187
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10188
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10189
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10190
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10191
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10192
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10193
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10194
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10195
canReadWithoutBlocking
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10196
    "return true, if data is available on a filedescriptor 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10197
     (i.e. read is possible without blocking).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10198
     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
 10199
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10200
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10201
    int fd;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10202
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10203
    if (__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10204
	fd = __smallIntegerVal(__INST(fd));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10205
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10206
	/*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10207
	 * if available, try FIONREAD first, which is usually done faster.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10208
	 */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10209
# ifdef FIONREAD
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10210
	{
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10211
	    int result = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10212
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10213
	    if (ioctl(fd, FIONREAD, &result) >= 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10214
		RETURN(result > 0 ? true : false);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10215
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10216
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10217
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10218
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10219
# if defined(__VMS__) && defined(DOES_NOT_WORK_YET)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10220
	{
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10221
	    /*
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10222
	     * do a sys$qio ..
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10223
	     * fd here is suposed to be a channel nr.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10224
	     */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10225
	    struct IOSB iosb;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10226
	    int status;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10227
	    int channel;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10228
	    struct typahdask sensebuf;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10229
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10230
	    status = SYS$QIO(0, /* efn */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10231
			     fd,
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10232
			     IO$_SENSEMODE | IO$M_TYPEAHDCNT,
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10233
			     &iosb,
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10234
			     0, /* ast */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10235
			     0, /* ast arg */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10236
			     &sensebuf,         /* data */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10237
			     sizeof(sensebuf),  /* data size */
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10238
			     0, 0, 0, 0);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10239
	    if (status != SS$_NORMAL) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10240
		fprintf(stderr, "OS [info]: SYS$QIO failed on %d\n", fd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10241
	    } else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10242
		fprintf(stderr, "sys$QIO -> %d\n", sensebuf.typcnt);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10243
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10244
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10245
# endif /* __VMS__ */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10246
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10247
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10248
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10249
    OperatingSystem supportsSelect ifFalse:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10250
	"/ mhmh - what should we do then ?
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10251
	"/ For now, return true as if data was present,
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10252
	"/ and let the thread fall into the read.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10253
	"/ It will then (hopefully) be desceduled there and
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10254
	"/ effectively polling for input.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10255
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10256
	^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10257
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10258
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10259
    ^ (OperatingSystem selectOnAnyReadable:(Array with:fd)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10260
		       writable:nil
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10261
		       exception:nil
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10262
		       withTimeOut:0) == fd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10263
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10264
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10265
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10266
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10267
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10268
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10269
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10270
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10271
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10272
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10273
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10274
     h := OperatingSystem openFileForRead:'/dev/ttyS0'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10275
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10276
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10277
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10278
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10279
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10280
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10281
canWriteWithoutBlocking
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10282
    "return true, if filedescriptor can be written without blocking"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10283
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10284
    OperatingSystem supportsSelect ifFalse:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10285
	"/ mhmh - what should we do then ?
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10286
	"/ For now, return true as if data was present,
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10287
	"/ and let the thread fall into the write.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10288
	"/ It will then (hopefully) be desceduled there and
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10289
	"/ effectively polling for output.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10290
	^ true
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10291
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10292
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10293
    ^ (OperatingSystem selectOnAnyReadable:nil
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10294
		       writable:(Array with:fd)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10295
		       exception:nil
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10296
		       withTimeOut:0) == fd
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10297
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10298
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10299
isValid
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10300
    "answer true, if the handle is valid, i.e. connected to
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10301
     a file or some other OS object"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10302
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10303
    ^ fd notNil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10304
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10305
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10306
numAvailableForRead
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10307
    "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
 10308
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10309
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10310
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10311
     * 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
 10312
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10313
# if defined(FIONREAD)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10314
    {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10315
	int n = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10316
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10317
	if (__isSmallInteger(__INST(fd))) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10318
	    if (ioctl(__smallIntegerVal(__INST(fd)), FIONREAD, &n) >= 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10319
		RETURN (__MKINT(n));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10320
	    }
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10321
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10322
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10323
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10324
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10325
    ^ self canReadWithoutBlocking ifTrue:[1] ifFalse:[0]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10326
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10327
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10328
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10329
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10330
     n := h numAvailableForRead.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10331
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10332
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10333
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10334
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10335
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10336
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10337
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10338
register
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10339
    "register myself as an open file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10340
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10341
    |sz old|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10342
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10343
    sz := OpenFiles size.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10344
    fd > sz ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10345
	"grow for more descriptors"
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10346
	old := OpenFiles.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10347
	OpenFiles := WeakArray new:(sz * 2).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10348
	old removeDependent:(self class).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10349
	OpenFiles addDependent:(self class).
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10350
	old keysAndValuesDo:[:index :elem|
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10351
	    "be careful to not overwrite new entries in OpenFiles"
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10352
	    elem notNil ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10353
		OpenFiles at:index put:elem.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10354
	    ].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10355
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10356
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10357
    OpenFiles at:fd put:self.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10358
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10359
    "Created: 30.9.1997 / 12:51:48 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10360
    "Modified: 30.9.1997 / 12:58:37 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10361
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10362
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10363
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10364
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10365
invalidate
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10366
    "a file handle has become invalid"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10367
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10368
    OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10369
    fd := nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10370
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10371
    "Created: 30.9.1997 / 12:37:26 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10372
    "Modified: 30.9.1997 / 12:42:16 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10373
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10374
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10375
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10376
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10377
readWaitWithTimeoutMs:timeout 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10378
    "suspend the current process, until the receiver
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10379
     becomes ready for reading or a timeout (in milliseconds) expired. 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10380
     If data is already available, return immediate. 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10381
     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
 10382
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10383
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10384
    |inputSema hasData wasBlocked|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10385
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10386
    fd isNil ifTrue:[^ self error:#errorNotOpen].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10387
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10388
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10389
    hasData := self canReadWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10390
    hasData ifFalse:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10391
	inputSema := Semaphore new name:'readWait'.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10392
	[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10393
	    timeout notNil ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10394
		Processor signal:inputSema afterMilliseconds:timeout 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10395
	    ].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10396
	    Processor signal:inputSema onInput:fd.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10397
	    Processor activeProcess state:#ioWait.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10398
	    inputSema wait.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10399
	    Processor disableSemaphore:inputSema.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10400
	    hasData := self canReadWithoutBlocking.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10401
	] ifCurtailed:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10402
	    Processor disableSemaphore:inputSema.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10403
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10404
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10405
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10406
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10407
    ^ hasData not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10408
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10409
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10410
writeWaitWithTimeoutMs:timeout
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10411
    "suspend the current process, until the receiver
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10412
     becomes ready for writing or a timeout (in seconds) expired. 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10413
     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
 10414
     Return immediate if the receiver is already ready. 
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10415
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10416
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
 10417
    |outputSema canWrite wasBlocked|
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10418
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10419
    fd isNil ifTrue:[^ self error:#errorNotOpen].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10420
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10421
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10422
    canWrite := self canWriteWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10423
    canWrite ifFalse:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10424
	outputSema := Semaphore new name:'writeWait'.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10425
	[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10426
	    timeout notNil ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10427
		Processor signal:outputSema afterMilliseconds:timeout
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10428
	    ].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10429
	    Processor signal:outputSema onOutput:fd.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10430
	    Processor activeProcess state:#ioWait.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10431
	    outputSema wait.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10432
	    Processor disableSemaphore:outputSema.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10433
	    canWrite := self canWriteWithoutBlocking.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10434
	] ifCurtailed:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10435
	    Processor disableSemaphore:outputSema.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10436
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10437
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10438
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10439
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10440
    ^ canWrite not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10441
! !
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10442
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10443
!UnixOperatingSystem::FilePointerHandle class methodsFor:'documentation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10444
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10445
version
6617
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
 10446
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.124 2002-07-10 11:46:34 stefan Exp $'
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10447
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10448
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10449
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10450
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10451
closeFile
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10452
    "close the underlying file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10453
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10454
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10455
    FILE *f = (FILE *)(__externalAddressVal(self));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10456
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10457
    if (f) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10458
	__externalAddressVal(self) = NULL;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10459
	fclose(f);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10460
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10461
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10462
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10463
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10464
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10465
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10466
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10467
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
 10468
    ^ self basicNew
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10469
	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
 10470
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10471
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10472
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10473
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10474
accessTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10475
    "return accessed"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10476
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10477
    ^ accessed
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10478
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10479
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10480
accessed
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10481
    "return accessed"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10482
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10483
    ^ accessed
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10484
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10485
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10486
alternativeName
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10487
    "return the files other name (DOS name on windows).
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10488
     Nil if there is no other name"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10489
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10490
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10491
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10492
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10493
fileSize
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10494
    "return size"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10495
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10496
    ^ size
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10497
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10498
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10499
fixedHeaderSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10500
    "return the fixedHeaderSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10501
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10502
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10503
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10504
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10505
gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10506
    "return gid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10507
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10508
    ^ gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10509
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10510
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10511
id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10512
    "return id"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10513
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10514
    ^ id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10515
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10516
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10517
mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10518
    "return mode"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10519
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10520
    ^ mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10521
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10522
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10523
modificationTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10524
    "return modified"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10525
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10526
    ^ modified
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10527
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10528
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10529
modified
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10530
    "return modified"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10531
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10532
    ^ modified
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10533
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10534
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10535
numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10536
    "return numLinks"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10537
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10538
    ^ numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10539
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10540
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10541
path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10542
    "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
 10543
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10544
    ^ path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10545
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10546
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10547
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10548
recordAttributes
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10549
    "return the recordAttributes (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10550
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10551
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10552
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10553
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10554
recordFormat
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10555
    "return the recordFormat (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10556
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10557
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10558
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10559
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10560
recordFormatNumeric
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10561
    "return the recordFormat as numeric (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10562
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10563
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10564
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10565
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10566
recordSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10567
    "return the recordSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10568
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10569
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10570
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10571
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10572
size
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10573
    "return size"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10574
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10575
    ^ size
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10576
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10577
6372
9cd3ac764491 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6371
diff changeset
 10578
statusChangeTime
9cd3ac764491 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6371
diff changeset
 10579
    "return statusChanged"
9cd3ac764491 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6371
diff changeset
 10580
9cd3ac764491 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6371
diff changeset
 10581
    ^ statusChanged
9cd3ac764491 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6371
diff changeset
 10582
!
9cd3ac764491 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6371
diff changeset
 10583
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10584
statusChanged
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10585
    "return statusChanged"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10586
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10587
    ^ statusChanged
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10588
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10589
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10590
type
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10591
    "return type"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10592
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10593
    ^ type
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10594
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10595
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10596
uid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10597
    "return uid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10598
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10599
    ^ uid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10600
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10601
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10602
!UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10603
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10604
at:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10605
    "backward compatibility access: in previous releases, IdentityDictionaries
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10606
     were used to hold my information. Allow access via key messages.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10607
     This method will vanish - use the proper access protocol."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10608
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10609
    ^ self perform:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10610
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10611
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10612
!UnixOperatingSystem::FileStatusInfo methodsFor:'private accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10613
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10614
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
 10615
    type := t.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10616
    mode := m.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10617
    uid := u.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10618
    gid := g.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10619
    size := s.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10620
    id := i.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10621
    accessed := aT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10622
    modified := mT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10623
    statusChanged := sT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10624
    path := lP.
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10625
    numLinks := nL.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10626
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10627
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10628
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10629
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10630
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10631
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10632
    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
 10633
    operating system processes (these are no smalltalk processes!!).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10634
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10635
    [Instance variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10636
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10637
	pid     <Integer>       OS-Process identifier
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10638
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10639
	status  <Symbol>        either #exit #signal #stop #continue
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10640
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10641
	code    <Integer>       either exitcode or signalnumber
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10642
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10643
	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
 10644
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10645
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10646
    [author:]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10647
	Stefan Vogel
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10648
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10649
    [see also:]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
 10650
	OperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10651
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10652
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10653
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10654
!UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10655
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10656
pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10657
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10658
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10659
    ^ 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
 10660
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10661
    "Created: 28.12.1995 / 14:16:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10662
    "Modified: 30.4.1996 / 18:25:00 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10663
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10664
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10665
processCreationFailure
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10666
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10667
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10668
    ^ 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
 10669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10670
    "Created: 28.12.1995 / 14:35:29 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10671
    "Modified: 30.4.1996 / 18:25:05 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10672
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10673
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10674
!UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10675
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10676
code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10677
    "return the exitcode / signalNumber"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10678
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10679
    ^ code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10680
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10681
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10682
    "Modified: 30.4.1996 / 18:26:23 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10683
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10684
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10685
core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10686
    "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
 10687
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10688
    ^ core == true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10689
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10690
    "Modified: 28.12.1995 / 14:14:38 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10691
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10692
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10693
pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10694
    "return the pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10695
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10696
    ^ pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10697
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10698
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10699
    "Modified: 30.4.1996 / 18:26:30 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10700
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10701
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10702
status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10703
    "return status as a Symbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10704
     one of #exit #signal #stop #continue"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10705
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10706
    ^ status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10707
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10708
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10709
    "Modified: 30.4.1996 / 18:26:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10710
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10711
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10712
!UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10713
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10714
pid:newPid status:newStatus code:newCode core:newCore
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10715
    pid := newPid.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10716
    status := newStatus.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10717
    code := newCode.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10718
    core := newCore.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10719
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10720
    "Created: 28.12.1995 / 14:18:22 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10721
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10722
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10723
!UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10725
code:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10726
    "set the exitCode"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10728
    code := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10729
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10730
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10731
    "Modified: 30.4.1996 / 18:25:18 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10732
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10733
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10734
core:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10735
    "set core"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10737
    core := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10738
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10739
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10740
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10741
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10742
pid:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10743
    "set pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10744
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10745
    pid := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10746
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10747
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10748
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10749
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10750
status:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10751
    "set status"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10752
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10753
    status := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10755
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10756
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10757
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10758
!UnixOperatingSystem::OSProcessStatus methodsFor:'queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10759
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10760
couldNotExecute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10761
    "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
 10762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10763
    ^ status == #exit and:[code = 127].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10764
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10765
    "Created: 28.12.1995 / 15:43:17 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10766
    "Modified: 30.4.1996 / 18:27:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10767
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10768
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10769
stillAlive
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10770
    "true if process is still alive"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10771
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10772
    ^ status == #stop or:[status == #continue]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10773
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10774
    "Created: 28.12.1995 / 14:27:26 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10775
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10776
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10777
success
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10778
    "true if process terminated successfully"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10779
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10780
    ^ status == #exit and:[code = 0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10781
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10782
    "Created: 28.12.1995 / 14:13:05 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10783
    "Modified: 28.12.1995 / 14:13:41 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10784
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10785
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10786
!UnixOperatingSystem::SocketHandle class methodsFor:'constants'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10787
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10788
domainCodeOf:aSymbolOrInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10789
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10790
    |domainCode|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10791
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10792
%{ /*NOCONTEXT*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10793
     int code = -1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10794
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10795
     if (__isSmallInteger(aSymbolOrInteger) || aSymbolOrInteger == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10796
	RETURN(aSymbolOrInteger);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10797
     }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10798
#ifdef AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10799
     else if (aSymbolOrInteger == @symbol(inet)) 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10800
	code = AF_INET;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10801
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10802
#ifdef AF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10803
     else if (aSymbolOrInteger == @symbol(inet6))
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10804
	code = AF_INET6;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10805
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10806
#ifdef AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10807
     else if (aSymbolOrInteger == @symbol(unix))
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10808
	code = AF_UNIX;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10809
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10810
#ifdef AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10811
     else if (aSymbolOrInteger == @symbol(appletalk))
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10812
	code = AF_APPLETALK;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10813
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10814
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10815
     if (code > 0)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10816
	 domainCode = __MKSMALLINT(code);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10817
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10818
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10819
    ^ domainCode.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10820
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10821
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10822
     self domainCodeOf:#inet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10823
     self domainCodeOf:#unix
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10824
     self domainCodeOf:#inet6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10825
     self domainCodeOf:#appletalk
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10826
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10827
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10828
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10829
domainSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10830
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10831
    |domainSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10832
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10833
%{ /*NOCONTEXT*/            
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10834
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10835
    if (__isSmallInteger(anInteger)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10836
	switch(__intVal(anInteger)) {
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10837
#ifdef AF_INET
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10838
	case AF_INET:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10839
	    domainSymbol = @symbol(inet);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10840
	    break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10841
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10842
#ifdef AF_INET6
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10843
	case AF_INET6:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10844
	    domainSymbol = @symbol(inet6);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10845
	    break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10846
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10847
#ifdef AF_UNIX
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10848
	case AF_UNIX:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10849
	    domainSymbol = @symbol(unix);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10850
	    break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10851
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10852
#ifdef AF_APPLETALK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10853
	case AF_APPLETALK:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10854
	    domainSymbol = @symbol(appletalk);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10855
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10856
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10857
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10858
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10859
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10860
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10861
    ^ domainSymbol.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10862
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10863
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10864
     self domainSymbolOf:(self domainCodeOf:#inet)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10865
     self domainSymbolOf:(self domainCodeOf:#inet6)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10866
     self domainSymbolOf:(self domainCodeOf:#unix)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10867
     self domainSymbolOf:(self domainCodeOf:#appletalk)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10868
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10869
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10870
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10871
protocolCodeOf:aNameOrNumber
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10872
    "convert a symbol to a numeric protocol code"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10873
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10874
    |protocolCode protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10875
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10876
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10877
    if (__isSmallInteger(aNameOrNumber) || aNameOrNumber == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10878
	RETURN(aNameOrNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10879
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10880
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10881
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10882
    ProtocolCache notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10883
	protocolCode := ProtocolCache at:aNameOrNumber asSymbol 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10884
				      ifAbsent:[].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10885
	protocolCode notNil ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10886
	    ^ protocolCode.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10887
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10888
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10889
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10890
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10891
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10892
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10893
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10894
    if (__isString(aNameOrNumber) || __isSymbol(aNameOrNumber)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10895
	protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10896
	if (protoent) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10897
	    protocolCode = __MKSMALLINT(protoent->p_proto);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10898
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10899
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10900
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10901
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10902
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10903
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10904
    protocolSymbol notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10905
	ProtocolCache isNil ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10906
	    ProtocolCache := IdentityDictionary new.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10907
	].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10908
	"beware of polluting the protocol cache with aliases"
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10909
	ProtocolCache at:protocolSymbol put:protocolCode.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10910
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10911
    ^ protocolCode
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10912
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10913
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10914
     self protocolCodeOf:#tcp
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10915
     self protocolCodeOf:#udp
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10916
     self protocolCodeOf:#raw
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10917
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10918
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10919
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10920
protocolSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10921
    "convert a numeric protocol code to a symbol"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10922
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10923
    |protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10924
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10925
    ProtocolCache notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10926
	protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10927
					ifAbsent:[].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10928
	protocolSymbol notNil ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10929
	    ^ protocolSymbol.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10930
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10931
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10932
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10933
%{ 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10934
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10935
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10936
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10937
    if (__isSmallInteger(anInteger)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10938
	protoent = getprotobynumber(__intVal(anInteger));
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10939
	if (protoent) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10940
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10941
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10942
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10943
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10944
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10945
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10946
    protocolSymbol notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10947
	ProtocolCache isNil ifTrue:[
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10948
	    ProtocolCache := IdentityDictionary new.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10949
	].
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10950
	ProtocolCache at:protocolSymbol put:anInteger.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10951
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10952
    ^ protocolSymbol
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10953
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10954
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10955
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10956
     self protocolSymbolOf:(self protocolCodeOf:#tcp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10957
     self protocolSymbolOf:(self protocolCodeOf:#udp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10958
     self protocolSymbolOf:(self protocolCodeOf:#icmp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10959
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10960
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10961
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10962
socketAddressSize:aSymbol
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10963
    "answer the os specific size of a socket address for domain aSymbol"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10964
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10965
    |socketSize|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10966
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10967
%{ /*NOCONTEXT*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10968
     int size = -1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10969
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10970
#ifdef AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10971
     if (aSymbol == @symbol(inet)) 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10972
	size = sizeof(struct sockaddr_in);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10973
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10974
#ifdef AF_INET6      
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10975
     else if (aSymbol == @symbol(inet6))
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10976
	size = sizeof(struct sockaddr_in6);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10977
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10978
#ifdef AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10979
     else if (aSymbol == @symbol(unix))
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10980
	size = sizeof(struct sockaddr_un);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10981
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10982
#ifdef AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10983
     else if (aSymbol == @symbol(appletalk))
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10984
	size = sizeof(struct sockaddr_at);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10985
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10986
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10987
     if (size > 0)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 10988
	 socketSize = __MKSMALLINT(size);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10989
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10990
    ^ socketSize
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10991
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10992
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10993
socketTypeCodeOf:aSymbolOrInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10994
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10995
    |typeCode|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10996
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10997
%{ /*NOCONTEXT*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10998
     int code = -1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10999
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11000
     if (__isSmallInteger(aSymbolOrInteger) || aSymbolOrInteger == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11001
	RETURN(aSymbolOrInteger);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11002
     }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11003
#ifdef SOCK_STREAM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11004
     else if (aSymbolOrInteger == @symbol(stream)) 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11005
	code = SOCK_STREAM;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11006
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11007
#ifdef SOCK_DGRAM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11008
     if (aSymbolOrInteger == @symbol(datagram)) 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11009
	code = SOCK_DGRAM;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11010
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11011
#ifdef SOCK_RAW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11012
     if (aSymbolOrInteger == @symbol(raw)) 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11013
	code = SOCK_RAW;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11014
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11015
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11016
     if (code > 0)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11017
	 typeCode = __MKSMALLINT(code);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11018
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11019
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11020
    ^ typeCode.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11021
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11022
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11023
     self socketTypeCodeOf:#stream
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11024
     self socketTypeCodeOf:#datagram
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11025
     self socketTypeCodeOf:#raw
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11026
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11027
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11028
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11029
socketTypeSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11030
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11031
    |socketTypeSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11032
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11033
%{ /*NOCONTEXT*/            
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11034
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11035
    if (__isSmallInteger(anInteger)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11036
	switch(__intVal(anInteger)) {
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11037
#ifdef SOCK_STREAM
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11038
	case SOCK_STREAM:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11039
	    socketTypeSymbol = @symbol(stream);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11040
	    break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11041
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11042
#ifdef SOCK_DGRAM
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11043
	case SOCK_DGRAM:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11044
	    socketTypeSymbol = @symbol(datagram);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11045
	    break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11046
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11047
#ifdef SOCK_RAW
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11048
	case SOCK_RAW:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11049
	    socketTypeSymbol = @symbol(raw);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11050
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11051
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11052
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11053
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11054
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11055
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11056
    ^ socketTypeSymbol.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11057
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11058
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11059
supportedProtocolFamilies
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11060
    "return a collection of supported protocol families.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11061
     This list specifies what the Socket class supports -
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11062
     socket creation may still fail, if your system was built
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11063
     without it."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11064
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11065
    |list|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11066
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11067
    list := OrderedCollection new.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11068
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11069
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11070
#ifdef AF_INET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11071
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11072
    list add:#inet.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11073
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11074
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11075
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11076
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11077
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11078
#ifdef AF_UNIX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11079
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11080
    list add:#unix.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11081
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11082
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11083
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11084
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11085
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11086
#ifdef AF_INET6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11087
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11088
    list add:#inet6.   "/ internet v6
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11089
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11090
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11091
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11092
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11093
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11094
#ifdef AF_APPLETALK
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11095
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11096
    list add:#appletalk.  "/ appletalk
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11097
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11098
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11099
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11100
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11101
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11102
#ifdef AF_DECnet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11103
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11104
    list add:#decnet.  "/ dec net
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11105
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11106
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11107
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11108
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11109
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11110
#ifdef AF_NS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11111
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11112
    list add:#xns.     "/ Xerox XNS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11113
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11114
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11115
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11116
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11117
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11118
#ifdef AF_X25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11119
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11120
    list add:#x25.     "/ X.25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11121
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11122
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11123
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11124
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11125
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11126
#ifdef AF_SNA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11127
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11128
    list add:#sna.     "/ IBM SNA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11129
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11130
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11131
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11132
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11133
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11134
#ifdef AF_RAW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11135
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11136
    list add:#raw.     "/ ?? RAW packets
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11137
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11138
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11139
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11140
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11141
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11142
#ifdef AF_ISO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11143
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11144
    list add:#iso.     "/ ??
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11145
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11146
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11147
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11148
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11149
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11150
#ifdef AF_NETBIOS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11151
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11152
    list add:#netbios. "/ ??
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11153
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11154
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11155
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11156
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11157
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11158
#ifdef AF_IPX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11159
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11160
    list add:#ipx.     "/ Novell IPX
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11161
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11162
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11163
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11164
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11165
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11166
#ifdef AF_AX25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11167
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11168
    list add:#ax25.    "/ Amateur Radio AX.25
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11169
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11170
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11171
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11172
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11173
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11174
#ifdef AF_NETROM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11175
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11176
    list add:#netrom.  "/ Amateur Radio NET/ROM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11177
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11178
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11179
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11180
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11181
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11182
#ifdef AF_BRIDGE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11183
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11184
    list add:#bridge.  "/ multiprotocol bridge
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11185
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11186
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11187
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11188
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11189
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11190
#ifdef AF_BSC
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11191
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11192
    list add:#bsc.     "/ BISYNC 2780/3780
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11193
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11194
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11195
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11196
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11197
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11198
#ifdef AF_ROSE
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11199
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11200
    list add:#rose.    "/ Amateur Radio X.25 PLP
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11201
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11202
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11203
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11204
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11205
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11206
#ifdef AF_IRDA
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11207
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11208
    list add:#irda.  "/ infrared
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11209
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11210
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11211
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11212
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11213
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11214
    ^ list
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11215
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11216
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11217
     self supportedProtocolFamilies
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11218
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11219
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11220
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11221
!UnixOperatingSystem::SocketHandle class methodsFor:'initialization'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11222
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11223
reinitialize
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11224
    "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
 11225
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11226
    ProtocolCache := nil.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11227
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11228
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11229
!UnixOperatingSystem::SocketHandle methodsFor:'accepting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11230
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11231
acceptWithPeerAddressBuffer:peerOrNil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11232
    "accept a connection on a server port.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11233
     Returns a new SocketHandle or nil if the operation
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11234
     would block.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11235
     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
 11236
     of the connection peer is stored into it."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11237
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11238
    |error newFd|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11239
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11240
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11241
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11242
    int sock, newSock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11243
    struct sockaddr *sap;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11244
    int alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11245
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11246
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11247
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11248
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11249
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11250
    if (peerOrNil != nil && 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11251
	(!__isNonNilObject(peerOrNil) ||
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11252
	 (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11253
	error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11254
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11255
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11256
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11257
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11258
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11259
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11260
    if (peerOrNil == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11261
	alen = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11262
	sap = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11263
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11264
	alen =  __byteArraySize(peerOrNil);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11265
	sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11266
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11267
    newSock = accept(sock, sap, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11268
    if (newSock < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11269
	switch (errno) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11270
	case EINTR:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11271
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11272
	    goto again;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11273
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11274
#ifdef EWOULDBLOCK
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11275
	case EWOULDBLOCK:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11276
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11277
#if defined(EAGAIN)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11278
	case EAGAIN:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11279
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11280
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11281
	    RETURN(nil);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11282
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11283
	default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11284
	    error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11285
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11286
	}
6350
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
    newFd = __mkSmallInteger(newSock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11289
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11290
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11291
#endif /* not NO_SOCKET */
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
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11294
	self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11295
    ] ifFalse:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11296
	^ self class for:newFd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11297
    ]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11298
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11299
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11300
!UnixOperatingSystem::SocketHandle methodsFor:'binding'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11301
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11302
bindTo:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11303
    "low level bind - 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11304
     Set the local address of the socket"
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
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11307
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11308
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11309
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11310
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11311
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11312
    int ret;
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
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11315
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11316
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11317
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11318
    if (!__isNonNilObject(socketAddress) ||
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11319
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11320
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11321
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11322
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11323
    sockaddr_size = __byteArraySize(socketAddress);
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
 11324
    sock = __smallIntegerVal(__INST(fd));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11325
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11326
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11327
    ret = bind(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11328
    if (ret < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11329
	if (errno == EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11330
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11331
	    goto again;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11332
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11333
	    error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11334
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11335
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11336
    }
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
    err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11339
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11340
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11341
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11342
	self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11343
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11344
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11345
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11346
     (Socket domain:#inet type:#stream)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11347
	 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11348
	 reuseAddress:false ;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11349
     yourself
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
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11352
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11353
!UnixOperatingSystem::SocketHandle methodsFor:'connecting'!
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
cancelConnect
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11356
    "cancel an asynchronous connect in progress"
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
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11359
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11360
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11361
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11362
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11363
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11364
    struct sockaddr sockaddr = { AF_UNSPEC };
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11365
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11366
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11367
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11368
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11369
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11370
    sock = __smallIntegerVal(__INST(fd));
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
    /* 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11373
     * (dis-) connect by connecting to AF_UNSPEC socket 
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 = connect(sock, &sockaddr, sizeof(sockaddr));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11377
    if (ret < 0) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11378
       switch(errno) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11379
       case EINTR:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11380
# ifdef EAGAIN
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11381
       case EAGAIN:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11382
# endif
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11383
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11384
	    goto again;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11385
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11386
	default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11387
	    error = __MKSMALLINT(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11388
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11389
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11390
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11391
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11392
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11393
#endif /* NO_SOCKET */
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11397
connectTo:socketAddress 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11398
    "low level connect; connect to a socket address.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11399
     Return true if connection has been established,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11400
     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
 11401
     completed. If an error occured, an OSError is raised"
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
    |error|
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
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11406
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11407
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11408
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11409
    int sockaddr_size;
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
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11412
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11413
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11414
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11415
    if (!__isNonNilObject(socketAddress) ||
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11416
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11417
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
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
    sockaddr_size = __qSize(socketAddress);
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
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11424
    ret = connect(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11425
    if (ret >= 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11426
	RETURN(true)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11427
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11428
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11429
    switch(errno) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11430
    case EINTR:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11431
# ifdef EAGAIN
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11432
    case EAGAIN:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11433
# endif
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11434
	__HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11435
	goto again;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11436
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11437
#if defined(EINPROGRESS) || defined(EALREADY)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11438
# ifdef EINPROGRESS
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11439
    case EINPROGRESS: 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11440
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11441
# ifdef EALREADY
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11442
    case EALREADY:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11443
# endif
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11444
	RETURN(false);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11445
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11446
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11447
    default:
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11448
	error = __MKSMALLINT(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11449
	break;
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11452
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11453
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11454
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11455
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11456
	self error:error.
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11457
	^ self
6350
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
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11461
     Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:7)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11462
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11463
     Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:5768)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11464
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11465
     Socket newTCP connectTo:(IPSocketAddress hostAddress:#[1 2 3 4] port:7)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11466
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11467
    "
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11470
!UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11471
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11472
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
 11473
    "receive datagramm data - put address of originating host into
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11474
     anAddressBuffer, data into aBuffer. For ST-80 compatibility,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11475
     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
 11476
     the addressBytes-message (i.e. be a SocketAddress instance).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11477
     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
 11478
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11479
     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
 11480
     receiving, using #readWait or #readWaitWithTimeout:."
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
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11483
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11484
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11485
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11486
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11487
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11488
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11489
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11490
    int alen0, alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11491
    int n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11492
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11493
    int __flags, __startIndex, __nBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11494
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11495
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11496
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11497
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11498
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11499
    if (!__isSmallInteger(startIndex) ||
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11500
	(__startIndex = __intVal(startIndex)-1) < 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11501
	if (startIndex == nil) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11502
	    __startIndex = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11503
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11504
	    error = @symbol(badArgument3);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11505
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11506
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11507
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11508
    if (__isSmallInteger(nBytes)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11509
	__nBytes = __intVal(nBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11510
    } else if (nBytes == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11511
	__nBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11512
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11513
	error = @symbol(badArgument4);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11514
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11515
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11516
    if (!__isInteger(flags)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11517
	error = @symbol(badArgument5);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11518
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11519
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11520
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11521
    sock = __smallIntegerVal(__INST(fd));
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
    oClass = __Class(aDataBuffer);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11524
    switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11525
	case BYTEARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11526
	case WORDARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11527
	case SWORDARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11528
	case LONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11529
	case SLONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11530
	case FLOATARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11531
	case DOUBLEARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11532
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11533
	default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11534
	    error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11535
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11536
    }
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
    nInstVars = __intVal(_ClassInstPtr(oClass)->c_ninstvars);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11539
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11540
    objSize = __qSize(aDataBuffer) - nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11541
    nInstBytes += __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11542
    objSize -= __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11543
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11544
    if (__nBytes >= 0 &&__nBytes < objSize) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11545
	objSize = __nBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11546
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11547
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11548
    if (socketAddress == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11549
	alen0 = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11550
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11551
	if (!__isNonNilObject(socketAddress) ||
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11552
	    (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11553
	    error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11554
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11555
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11556
	alen0 = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11557
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11558
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11559
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11560
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11561
    alen = alen0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11562
    if (alen)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11563
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11564
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11565
    n = recvfrom(sock, cp, objSize, __flags, saPtr, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11566
    if (n < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11567
	if (errno == EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11568
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11569
	    goto again;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11570
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11571
	    error = __MKSMALLINT(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11572
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11573
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11574
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11575
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11576
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11577
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11578
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11579
    self error:error.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11580
    ^ -1
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11581
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11582
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11583
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
 11584
    "send datagramm data - fetch address of destination host from
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11585
     anAddressBuffer, data from aDataBuffer starting at startIndex,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11586
     sending count bytes.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11587
     SocketAddress must be an instance of SocketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11588
     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
 11589
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11590
    |error|
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
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11593
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11594
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11595
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11596
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11597
    int alen, n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11598
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11599
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11600
    int __flags;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11601
    int offs, __startIndex, __maxBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11602
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11603
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11604
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11605
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11606
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11607
    if (!__isSmallInteger(startIndex) ||
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11608
	(__startIndex = __intVal(startIndex)-1) < 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11609
	if (startIndex == nil) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11610
	    __startIndex = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11611
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11612
	    error = @symbol(badArgument3);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11613
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11614
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11615
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11616
    if (__isSmallInteger(maxBytes)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11617
	__maxBytes = __intVal(maxBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11618
    } else if (maxBytes == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11619
	__maxBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11620
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11621
	error = @symbol(badArgument4);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11622
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11623
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11624
    if (!__isInteger(flags)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11625
	error = @symbol(badArgument5);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11626
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11627
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11628
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11629
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11630
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11631
    oClass = __Class(aDataBuffer);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11632
    switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11633
	case BYTEARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11634
	    offs = __startIndex;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11635
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11636
	case WORDARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11637
	case SWORDARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11638
	    offs = __startIndex * 2;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11639
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11640
	case LONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11641
	case SLONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11642
	    offs = __startIndex * 4;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11643
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11644
	case LONGLONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11645
	case SLONGLONGARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11646
	    offs = __startIndex * 8;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11647
# ifdef __NEED_LONGLONG_ALIGN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11648
	    offs += 4;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11649
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11650
	case FLOATARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11651
	    offs = __startIndex * sizeof(float);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11652
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11653
	case DOUBLEARRAY:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11654
	    offs = __startIndex * sizeof(double);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11655
# ifdef __NEED_DOUBLE_ALIGN
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11656
	    offs += 4;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11657
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11658
	    break;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11659
	default:
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11660
	    error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11661
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11662
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11663
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11664
    nInstVars = __smallIntegerVal(_ClassInstPtr(oClass)->c_ninstvars);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11665
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11666
    objSize = __qSize(aDataBuffer) - nInstBytes - offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11667
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11668
    if (__maxBytes >= 0 && __maxBytes < objSize) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11669
# ifdef DGRAM_DEBUG
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11670
	printf("cut off ...\n");
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11671
# endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11672
	objSize = __maxBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11673
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11674
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11675
    if (socketAddress == nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11676
	alen = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11677
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11678
	if (! __isByteArray(socketAddress)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11679
	    error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11680
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11681
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11682
	alen = __byteArraySize(socketAddress);
6350
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
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11685
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11686
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11687
    if (alen)
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11688
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11689
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes + offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11690
    n = sendto(sock, cp, objSize, __flags, saPtr, alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11691
    if (n < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11692
	if (errno == EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11693
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11694
	    goto again;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11695
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11696
	    error = __MKSMALLINT(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11697
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11698
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11699
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11700
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11701
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11702
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11703
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11704
    self error:error.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11705
    ^ -1
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11706
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11707
6434
f23d12900e18 category rename
Claus Gittinger <cg@exept.de>
parents: 6421
diff changeset
 11708
!UnixOperatingSystem::SocketHandle methodsFor:'initialization'!
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11709
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11710
domain:domainArg type:typeArg protocol:protocolArg 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11711
    "set up socket with domain, type and protocol number.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11712
     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
 11713
     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
 11714
     #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp."
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
    |error domainCode protocolNumber|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11717
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11718
    domainCode := self class domainCodeOf:domainArg.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11719
    protocolArg notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11720
	protocolNumber := self class protocolCodeOf:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11721
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11722
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11723
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11724
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11725
    int dom, typ, proto = 0, sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11726
    int on = 1;
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 (__INST(fd) != nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11729
	error = @symbol(internalError);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11730
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11731
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11732
    if (! __isSmallInteger(domainCode)) { 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11733
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11734
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11735
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11736
    if (! __isSymbol(typeArg)) { 
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11737
	error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11738
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11739
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11740
    if (protocolNumber != nil) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11741
	if (!__isSmallInteger(protocolNumber)) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11742
	    error = @symbol(badArgument3);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11743
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11744
	}
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11745
	proto = __smallIntegerVal(protocolNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11746
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11747
    dom = __smallIntegerVal(domainCode);    
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11748
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11749
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11750
     * get socket-type and protocol-type
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11751
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11752
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11753
#ifdef SOCK_STREAM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11754
    if (typeArg == @symbol(stream)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11755
	typ = SOCK_STREAM;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11756
    } else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11757
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11758
#ifdef SOCK_DGRAM
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11759
    if (typeArg == @symbol(datagram)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11760
	typ = SOCK_DGRAM;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11761
    } else 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11762
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11763
#ifdef SOCK_RAW
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11764
    if (typeArg == @symbol(raw))
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11765
	typ = SOCK_RAW;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11766
    else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11767
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11768
#ifdef SOCK_SEQPACKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11769
    if (typeArg == @symbol(seqPacket))
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11770
	typ = SOCK_SEQPACKET;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11771
    else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11772
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11773
    {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11774
	error = @symbol(badArgument2);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11775
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11776
    }
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
againSocket:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11779
    sock = socket(dom, typ, proto);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11780
    if (sock < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11781
	if (errno == EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11782
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11783
	    goto againSocket;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11784
	} else 
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11785
#if defined(EPROTONOSUPPORT) /* for SGI */
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11786
	if (errno == EPROTONOSUPPORT && proto != 0) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11787
	    proto = 0;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11788
	    goto againSocket;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11789
	} else
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11790
#endif
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11791
	{
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11792
	    error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11793
	    goto err;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11794
	}
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
    __INST(fd) = __mkSmallInteger(sock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11797
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11798
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11799
#else
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11800
    error := @symbol(notImplemented);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11801
#endif
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
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11804
	^ self error:error.
6350
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
    self register.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11807
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11808
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11809
     self new domain:#inet type:#stream protocol:nil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11810
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11811
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11812
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11813
!UnixOperatingSystem::SocketHandle methodsFor:'misc'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11814
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11815
getOptionsLevel:level name:name 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11816
    "answer a ByteArray containing the socket option value 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11817
     named name at level"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11818
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11819
    |error bytes size|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11820
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11821
    bytes := ByteArray new:256.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11822
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11823
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11824
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11825
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11826
    int intval, sz;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11827
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11828
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11829
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11830
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11831
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11832
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11833
    if (!__bothSmallInteger(level, name)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11834
	error = @symbol(badArgument);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11835
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11836
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11837
    if (!__isByteArray(bytes)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11838
	error = @symbol(internalError);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11839
	goto err;
6350
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
    p = __byteArrayVal(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11842
    sz = __byteArraySize(bytes);
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
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11845
    if (getsockopt(sock, __smallIntegerVal(level), __smallIntegerVal(name), p, &sz) < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11846
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11847
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11848
    size = __mkSmallInteger(sz);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11849
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11850
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11851
#endif
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
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11854
	^ self error:error
6350
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
    ^ bytes copyTo:size
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11857
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11858
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11859
listenFor:aNumber 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11860
    "start listening.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11861
     aNumber is the number of connect indications queues
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11862
     by the operating system"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11863
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11864
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11865
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11866
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11867
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11868
    int sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11869
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11870
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11871
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11872
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11873
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11874
    if (!__isSmallInteger(aNumber)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11875
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11876
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11877
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11878
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11879
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11880
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11881
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11882
    ret = listen(sock, __smallIntegerVal(aNumber));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11883
    if (ret < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11884
	if (errno == EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11885
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11886
	    goto again;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11887
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11888
	    error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11889
	}
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11892
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11893
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11894
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11895
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11896
	self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11897
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11898
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11899
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11900
setOptionsLevel:level name:name value:value 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11901
    "set the socket option name at level to value.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11902
     Value ay be one of SmallInteger, ByteArray or nil"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11903
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11904
    |error|
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
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11907
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11908
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11909
    int intval, sz;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11910
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11911
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11912
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11913
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11914
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11915
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11916
    if (!__bothSmallInteger(level, name)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11917
	error = @symbol(badArgument);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11918
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11919
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11920
    if (__isSmallInteger(value)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11921
	intval = __intVal(value);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11922
	p = (char *) &intval;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11923
	sz = sizeof(intval);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11924
    } else if (__isByteArray(value)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11925
	p = __byteArrayVal(value);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11926
	sz = __byteArraySize(value);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11927
    } else {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11928
	error = @symbol(badArgument3);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11929
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11930
    }
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
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11933
    if (setsockopt(sock, __smallIntegerVal(level), __smallIntegerVal(name), p, sz) < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11934
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11935
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11936
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11937
#endif
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
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11940
	^ self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11941
    ]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11942
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11943
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11944
shutdown:anInteger 
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11945
    "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
 11946
     anInteger == 0   no reads will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11947
     anInteger == 1   no writes will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11948
     anInteger == 2   neither reads nor writes will be performed.
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11949
		      Pending data is discarded. This is faster tha 
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11950
		      close, which may wait until pending (written)
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11951
		      data has been read by the other side"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11952
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11953
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11954
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11955
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11956
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11957
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11958
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11959
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11960
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11961
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11962
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11963
    if (!__isSmallInteger(anInteger)) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11964
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11965
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11966
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11967
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11968
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11969
    ret = shutdown(__smallIntegerVal(__INST(fd)), __smallIntegerVal(anInteger));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11970
    if (ret < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11971
	if (errno == EINTR) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11972
	    __HANDLE_INTERRUPTS__;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11973
	    goto again;
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11974
	} else {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11975
	    error = __mkSmallInteger(errno);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11976
	}
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
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11980
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11981
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11982
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 11983
	self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11984
    ]
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11987
!UnixOperatingSystem::SocketHandle methodsFor:'queries'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11988
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11989
getNameInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11990
    "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
 11991
     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
 11992
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11993
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11994
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11995
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11996
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11997
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11998
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11999
    int ret;
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
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12002
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12003
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12004
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12005
    if (!__isNonNilObject(socketAddress) ||
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12006
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12007
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12008
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12009
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12010
    sockaddr_size = __byteArraySize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12011
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12012
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12013
    ret = getsockname(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12014
    if (ret < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12015
	error = __MKSMALLINT(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12016
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12017
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12018
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12019
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12020
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12021
	^ self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12022
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12023
    ^ socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12024
!
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
getPeerInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12027
    "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
 12028
     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
 12029
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12030
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12031
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12032
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12033
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12034
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12035
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12036
    int ret;
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
    if (!__isSmallInteger(__INST(fd))) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12039
	error = @symbol(badFd);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12040
	goto err;
6350
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
    if (!__isNonNilObject(socketAddress) ||
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12043
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12044
	error = @symbol(badArgument1);
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12045
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12046
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12047
    sockaddr_size = __byteArraySize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12048
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12049
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12050
    ret = getpeername(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12051
    if (ret < 0) {
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12052
	error = __mkSmallInteger(errno);
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
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12055
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12056
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12057
    error notNil ifTrue:[
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
 12058
	^ self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12059
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12060
    ^ socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12061
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12062
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12063
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12064
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12065
version
6617
e582d421c0b7 Share and close /dev/null filediscriptors.
Stefan Vogel <sv@exept.de>
parents: 6579
diff changeset
 12066
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.124 2002-07-10 11:46:34 stefan Exp $'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12067
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 12068
UnixOperatingSystem initialize!